summaryrefslogtreecommitdiff
path: root/src/index.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/index.zig')
-rw-r--r--src/index.zig22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/index.zig b/src/index.zig
index dde4748..5900424 100644
--- a/src/index.zig
+++ b/src/index.zig
@@ -23,14 +23,6 @@ pub const Names = struct {
23 /// '--' prefix 23 /// '--' prefix
24 long: ?[]const u8, 24 long: ?[]const u8,
25 25
26 /// Initializes no names
27 pub fn positional() Names {
28 return Names{
29 .short = null,
30 .long = null,
31 };
32 }
33
34 /// Initializes a short name 26 /// Initializes a short name
35 pub fn short(s: u8) Names { 27 pub fn short(s: u8) Names {
36 return Names{ 28 return Names{
@@ -87,7 +79,19 @@ pub fn Param(comptime Id: type) type {
87 takes_value: bool, 79 takes_value: bool,
88 names: Names, 80 names: Names,
89 81
90 pub fn init(id: Id, takes_value: bool, names: Names) @This() { 82 pub fn flag(id: Id, names: Names) @This() {
83 return init(id, false, names);
84 }
85
86 pub fn option(id: Id, names: Names) @This() {
87 return init(id, true, names);
88 }
89
90 pub fn positional(id: Id) @This() {
91 return init(id, true, Names{ .short = null, .long = null });
92 }
93
94 fn init(id: Id, takes_value: bool, names: Names) @This() {
91 // Assert, that if the param have no name, then it has to take 95 // Assert, that if the param have no name, then it has to take
92 // a value. 96 // a value.
93 debug.assert( 97 debug.assert(