diff options
Diffstat (limited to '')
| -rw-r--r-- | example.zig | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/example.zig b/example.zig index 14b5487..4b3fa82 100644 --- a/example.zig +++ b/example.zig | |||
| @@ -1,14 +1,9 @@ | |||
| 1 | const std = @import("std"); | 1 | const std = @import("std"); |
| 2 | const core = @import("core.zig"); | 2 | const clap = @import("index.zig"); |
| 3 | const clap = @import("extended.zig"); | ||
| 4 | 3 | ||
| 5 | const debug = std.debug; | 4 | const debug = std.debug; |
| 6 | const os = std.os; | 5 | const os = std.os; |
| 7 | 6 | ||
| 8 | const Clap = clap.Clap; | ||
| 9 | const Param = clap.Param; | ||
| 10 | const Parser = clap.Parser; | ||
| 11 | |||
| 12 | const Options = struct { | 7 | const Options = struct { |
| 13 | print_values: bool, | 8 | print_values: bool, |
| 14 | a: i64, | 9 | a: i64, |
| @@ -35,7 +30,7 @@ const Options = struct { | |||
| 35 | // d = V=5 | 30 | // d = V=5 |
| 36 | 31 | ||
| 37 | pub fn main() !void { | 32 | pub fn main() !void { |
| 38 | const parser = comptime Clap(Options) { | 33 | const parser = comptime clap.Clap(Options) { |
| 39 | .defaults = Options { | 34 | .defaults = Options { |
| 40 | .print_values = false, | 35 | .print_values = false, |
| 41 | .a = 0, | 36 | .a = 0, |
| @@ -43,22 +38,22 @@ pub fn main() !void { | |||
| 43 | .c = 0, | 38 | .c = 0, |
| 44 | .d = "", | 39 | .d = "", |
| 45 | }, | 40 | }, |
| 46 | .params = []Param { | 41 | .params = []clap.Param { |
| 47 | Param.init("a") | 42 | clap.Param.smart("a") |
| 48 | .with("takes_value", Parser.int(i64, 10)), | 43 | .with("takes_value", clap.Parser.int(i64, 10)), |
| 49 | Param.init("b") | 44 | clap.Param.smart("b") |
| 50 | .with("takes_value", Parser.int(u64, 10)), | 45 | .with("takes_value", clap.Parser.int(u64, 10)), |
| 51 | Param.init("c") | 46 | clap.Param.smart("c") |
| 52 | .with("takes_value", Parser.int(u8, 10)), | 47 | .with("takes_value", clap.Parser.int(u8, 10)), |
| 53 | Param.init("d") | 48 | clap.Param.smart("d") |
| 54 | .with("takes_value", Parser.string), | 49 | .with("takes_value", clap.Parser.string), |
| 55 | Param.init("print_values") | 50 | clap.Param.smart("print_values") |
| 56 | .with("short", 'p') | 51 | .with("short", 'p') |
| 57 | .with("long", "print-values"), | 52 | .with("long", "print-values"), |
| 58 | } | 53 | } |
| 59 | }; | 54 | }; |
| 60 | 55 | ||
| 61 | var arg_iter = core.OsArgIterator.init(); | 56 | var arg_iter = clap.core.OsArgIterator.init(); |
| 62 | const iter = &arg_iter.iter; | 57 | const iter = &arg_iter.iter; |
| 63 | const command = iter.next(debug.global_allocator); | 58 | const command = iter.next(debug.global_allocator); |
| 64 | 59 | ||