summaryrefslogtreecommitdiff
path: root/clap.zig
diff options
context:
space:
mode:
authorGravatar Komari Spaghetti2021-06-24 17:20:53 +0200
committerGravatar Komari Spaghetti2021-06-24 17:20:53 +0200
commitfb2ee06520e3620b8e711e79d45329ff2dc076a1 (patch)
treeec51c6cdfdaf66c08d09b833e9aa08898dbb73f5 /clap.zig
parentparse: Copy in arena after using it in parseEx (diff)
downloadzig-clap-fb2ee06520e3620b8e711e79d45329ff2dc076a1.tar.gz
zig-clap-fb2ee06520e3620b8e711e79d45329ff2dc076a1.tar.xz
zig-clap-fb2ee06520e3620b8e711e79d45329ff2dc076a1.zip
parseParam: Set eval quota to std.math.maxInt(u32)
fixes #42 related #39
Diffstat (limited to 'clap.zig')
-rw-r--r--clap.zig10
1 files changed, 10 insertions, 0 deletions
diff --git a/clap.zig b/clap.zig
index 20cf25d..1e47b42 100644
--- a/clap.zig
+++ b/clap.zig
@@ -63,6 +63,16 @@ pub fn Param(comptime Id: type) type {
63/// Takes a string and parses it to a Param(Help). 63/// Takes a string and parses it to a Param(Help).
64/// This is the reverse of 'help' but for at single parameter only. 64/// This is the reverse of 'help' but for at single parameter only.
65pub fn parseParam(line: []const u8) !Param(Help) { 65pub fn parseParam(line: []const u8) !Param(Help) {
66 // This function become a lot less ergonomic to use once you hit the eval branch quota. To
67 // avoid this we pick a sane default. Sadly, the only sane default is the biggest possible
68 // value. If we pick something a lot smaller and a user hits the quota after that, they have
69 // no way of overriding it, since we set it here.
70 // We can recosider this again if:
71 // * We get parseParams: https://github.com/Hejsil/zig-clap/issues/39
72 // * We get a larger default branch quota in the zig compiler (stage 2).
73 // * Someone points out how this is a really bad idea.
74 @setEvalBranchQuota(std.math.maxInt(u32));
75
66 var found_comma = false; 76 var found_comma = false;
67 var it = mem.tokenize(line, " \t"); 77 var it = mem.tokenize(line, " \t");
68 var param_str = it.next() orelse return error.NoParamFound; 78 var param_str = it.next() orelse return error.NoParamFound;