diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/extended.zig | 54 |
1 files changed, 25 insertions, 29 deletions
diff --git a/src/extended.zig b/src/extended.zig index 5fd019d..ec8310e 100644 --- a/src/extended.zig +++ b/src/extended.zig | |||
| @@ -16,40 +16,48 @@ pub const Param = struct { | |||
| 16 | settings: Settings, | 16 | settings: Settings, |
| 17 | kind: Kind, | 17 | kind: Kind, |
| 18 | 18 | ||
| 19 | pub fn flag(field: []const u8, names: *const core.Names, settings: *const Settings) Param { | 19 | required: bool, |
| 20 | return Param{ | 20 | position: ?usize, |
| 21 | .field = field, | 21 | |
| 22 | .names = names.*, | 22 | pub fn flag(field: []const u8, names: *const core.Names) Param { |
| 23 | .settings = settings.*, | 23 | return init( |
| 24 | .kind = Kind.Flag, | 24 | field, |
| 25 | }; | 25 | names, |
| 26 | Kind.Flag, | ||
| 27 | ); | ||
| 26 | } | 28 | } |
| 27 | 29 | ||
| 28 | pub fn option( | 30 | pub fn option( |
| 29 | field: []const u8, | 31 | field: []const u8, |
| 30 | names: *const core.Names, | 32 | names: *const core.Names, |
| 31 | settings: *const Settings, | ||
| 32 | comptime parser: *const Parser, | 33 | comptime parser: *const Parser, |
| 33 | ) Param { | 34 | ) Param { |
| 34 | return Param{ | 35 | return init( |
| 35 | .field = field, | 36 | field, |
| 36 | .names = names.*, | 37 | names, |
| 37 | .settings = settings.*, | 38 | Kind{ .Option = parser.* }, |
| 38 | .kind = Kind{ .Option = parser.* }, | 39 | ); |
| 39 | }; | ||
| 40 | } | 40 | } |
| 41 | 41 | ||
| 42 | pub fn subcommand( | 42 | pub fn subcommand( |
| 43 | field: []const u8, | 43 | field: []const u8, |
| 44 | names: *const core.Names, | 44 | names: *const core.Names, |
| 45 | settings: *const Settings, | ||
| 46 | comptime command: *const Command, | 45 | comptime command: *const Command, |
| 47 | ) Param { | 46 | ) Param { |
| 47 | return init( | ||
| 48 | field, | ||
| 49 | names, | ||
| 50 | Kind{ .Subcommand = command.* }, | ||
| 51 | ); | ||
| 52 | } | ||
| 53 | |||
| 54 | pub fn init(field: []const u8, names: *const core.Names, kind: *const Kind) Param { | ||
| 48 | return Param{ | 55 | return Param{ |
| 49 | .field = field, | 56 | .field = field, |
| 50 | .names = names.*, | 57 | .names = names.*, |
| 51 | .settings = settings.*, | 58 | .kind = kind.*, |
| 52 | .kind = Kind{ .Subcommand = Command.* }, | 59 | .required = false, |
| 60 | .position = null, | ||
| 53 | }; | 61 | }; |
| 54 | } | 62 | } |
| 55 | 63 | ||
| @@ -58,18 +66,6 @@ pub const Param = struct { | |||
| 58 | Option: Parser, | 66 | Option: Parser, |
| 59 | Subcommand: Command, | 67 | Subcommand: Command, |
| 60 | }; | 68 | }; |
| 61 | |||
| 62 | pub const Settings = struct { | ||
| 63 | required: bool, | ||
| 64 | position: ?usize, | ||
| 65 | |||
| 66 | pub fn default() Settings { | ||
| 67 | return Settings{ | ||
| 68 | .required = false, | ||
| 69 | .position = null, | ||
| 70 | }; | ||
| 71 | } | ||
| 72 | }; | ||
| 73 | }; | 69 | }; |
| 74 | 70 | ||
| 75 | const Opaque = @OpaqueType(); | 71 | const Opaque = @OpaqueType(); |