summaryrefslogtreecommitdiff
path: root/clap.zig
diff options
context:
space:
mode:
authorGravatar Jimmi Holst Christensen2026-02-14 18:19:39 +0100
committerGravatar Jimmi Holst Christensen2026-02-14 18:20:29 +0100
commit27621cb7207643f914bae7b01902b22a8b5916e7 (patch)
tree364101291469a91343b990072db70ebcc4ed0dd9 /clap.zig
parentfix: use new `std.process.Init` args for Zig `0.16.0-dev.2261+d6b3dd25a` (#175) (diff)
downloadzig-clap-27621cb7207643f914bae7b01902b22a8b5916e7.tar.gz
zig-clap-27621cb7207643f914bae7b01902b22a8b5916e7.tar.xz
zig-clap-27621cb7207643f914bae7b01902b22a8b5916e7.zip
fix: Add compile error when positional taking many values is not lastHEADmaster
See https://github.com/Hejsil/zig-clap/issues/153
Diffstat (limited to 'clap.zig')
-rw-r--r--clap.zig18
1 files changed, 18 insertions, 0 deletions
diff --git a/clap.zig b/clap.zig
index 54bcb32..00f195b 100644
--- a/clap.zig
+++ b/clap.zig
@@ -899,6 +899,24 @@ fn Positionals(
899 if (longest.kind != .positional) 899 if (longest.kind != .positional)
900 continue; 900 continue;
901 901
902 if ((i + 1) != fields_len and param.takes_value == .many) {
903 @compileError(
904 \\Only the last positional is allowed to take multiple values
905 \\This works:
906 \\ <usize>
907 \\ <str>
908 \\ <str>...
909 \\
910 \\This doesn't:
911 \\ <usize>
912 \\ <str>...
913 \\ <str>
914 \\
915 \\See https://github.com/Hejsil/zig-clap/issues/153
916 \\
917 );
918 }
919
902 const T = ParamType(Id, param, value_parsers); 920 const T = ParamType(Id, param, value_parsers);
903 const FieldT = switch (param.takes_value) { 921 const FieldT = switch (param.takes_value) {
904 .none => continue, 922 .none => continue,