slovo/lib/std/cli.slo
2026-05-22 08:38:43 +02:00

158 lines
4.1 KiB
Plaintext

(module cli (export arg_text_result arg_text_option arg_i32_result arg_i32_option arg_i32_or_zero arg_i32_or arg_u32_result arg_u32_option arg_u32_or_zero arg_u32_or arg_i64_result arg_i64_option arg_i64_or_zero arg_i64_or arg_u64_result arg_u64_option arg_u64_or_zero arg_u64_or arg_f64_result arg_f64_option arg_f64_or_zero arg_f64_or arg_bool_result arg_bool_option arg_bool_or_false arg_bool_or))
(import std.process (arg_result))
(import std.result (ok_or_none_string ok_or_none_i32 ok_or_none_u32 ok_or_none_i64 ok_or_none_u64 ok_or_none_f64 ok_or_none_bool))
(import std.string (parse_i32_result parse_u32_result parse_i64_result parse_u64_result parse_f64_result parse_bool_result))
(fn arg_text_result ((index i32)) -> (result string i32)
(arg_result index))
(fn arg_text_option ((index i32)) -> (option string)
(ok_or_none_string (arg_text_result index)))
(fn arg_i32_result ((index i32)) -> (result i32 i32)
(match (arg_result index)
((ok text)
(parse_i32_result text))
((err code)
(err i32 i32 code))))
(fn arg_i32_option ((index i32)) -> (option i32)
(ok_or_none_i32 (arg_i32_result index)))
(fn arg_i32_or_zero ((index i32)) -> i32
(match (arg_i32_result index)
((ok value)
value)
((err code)
0)))
(fn arg_i32_or ((index i32) (fallback i32)) -> i32
(match (arg_i32_result index)
((ok value)
value)
((err code)
fallback)))
(fn arg_u32_result ((index i32)) -> (result u32 i32)
(match (arg_result index)
((ok text)
(parse_u32_result text))
((err code)
(err u32 i32 code))))
(fn arg_u32_option ((index i32)) -> (option u32)
(ok_or_none_u32 (arg_u32_result index)))
(fn arg_u32_or_zero ((index i32)) -> u32
(match (arg_u32_result index)
((ok value)
value)
((err code)
0u32)))
(fn arg_u32_or ((index i32) (fallback u32)) -> u32
(match (arg_u32_result index)
((ok value)
value)
((err code)
fallback)))
(fn arg_i64_result ((index i32)) -> (result i64 i32)
(match (arg_result index)
((ok text)
(parse_i64_result text))
((err code)
(err i64 i32 code))))
(fn arg_i64_option ((index i32)) -> (option i64)
(ok_or_none_i64 (arg_i64_result index)))
(fn arg_i64_or_zero ((index i32)) -> i64
(match (arg_i64_result index)
((ok value)
value)
((err code)
0i64)))
(fn arg_i64_or ((index i32) (fallback i64)) -> i64
(match (arg_i64_result index)
((ok value)
value)
((err code)
fallback)))
(fn arg_u64_result ((index i32)) -> (result u64 i32)
(match (arg_result index)
((ok text)
(parse_u64_result text))
((err code)
(err u64 i32 code))))
(fn arg_u64_option ((index i32)) -> (option u64)
(ok_or_none_u64 (arg_u64_result index)))
(fn arg_u64_or_zero ((index i32)) -> u64
(match (arg_u64_result index)
((ok value)
value)
((err code)
0u64)))
(fn arg_u64_or ((index i32) (fallback u64)) -> u64
(match (arg_u64_result index)
((ok value)
value)
((err code)
fallback)))
(fn arg_f64_result ((index i32)) -> (result f64 i32)
(match (arg_result index)
((ok text)
(parse_f64_result text))
((err code)
(err f64 i32 code))))
(fn arg_f64_option ((index i32)) -> (option f64)
(ok_or_none_f64 (arg_f64_result index)))
(fn arg_f64_or_zero ((index i32)) -> f64
(match (arg_f64_result index)
((ok value)
value)
((err code)
0.0)))
(fn arg_f64_or ((index i32) (fallback f64)) -> f64
(match (arg_f64_result index)
((ok value)
value)
((err code)
fallback)))
(fn arg_bool_result ((index i32)) -> (result bool i32)
(match (arg_result index)
((ok text)
(parse_bool_result text))
((err code)
(err bool i32 code))))
(fn arg_bool_option ((index i32)) -> (option bool)
(ok_or_none_bool (arg_bool_result index)))
(fn arg_bool_or_false ((index i32)) -> bool
(match (arg_bool_result index)
((ok value)
value)
((err code)
false)))
(fn arg_bool_or ((index i32) (fallback bool)) -> bool
(match (arg_bool_result index)
((ok value)
value)
((err code)
fallback)))