diff options
author | 2023-02-28 13:49:05 -0800 | |
---|---|---|
committer | 2023-02-28 13:49:05 -0800 | |
commit | 7b9a17f9d7106ffd8e553a5192aba60d14ea5e9c (patch) | |
tree | 0aebdc62db0e8bfbf0db537537cb1c8ac6844772 /misctools | |
parent | bd91aa8c25a05768cae5a0df482bb8f50c599c20 (diff) | |
download | bun-7b9a17f9d7106ffd8e553a5192aba60d14ea5e9c.tar.gz bun-7b9a17f9d7106ffd8e553a5192aba60d14ea5e9c.tar.zst bun-7b9a17f9d7106ffd8e553a5192aba60d14ea5e9c.zip |
Update clap (#2238)
* remove vendored clap
* Update to latest zig-clap
Major changes:
* Instead of vendoring zig-clap and adding changes, this uses Hejsil/zig-clap directly as a submodule
* `cli.zig` and related files have been updated to use new API (no more `flag()` or `option()`)
* A workaround for the Run and Auto commands has been implemented that allows us to use the official upstream
Minor change:
* `-i` now has the long option `--install-fallback`; I didn't spend much time thinking about this name, so suggestions weclome.
* deinit jsBundleArgs
Diffstat (limited to 'misctools')
-rw-r--r-- | misctools/fetch.zig | 16 | ||||
-rw-r--r-- | misctools/http_bench.zig | 22 |
2 files changed, 19 insertions, 19 deletions
diff --git a/misctools/fetch.zig b/misctools/fetch.zig index cdefd29d4..85f21c3b7 100644 --- a/misctools/fetch.zig +++ b/misctools/fetch.zig @@ -78,7 +78,7 @@ pub const Arguments = struct { pub fn parse(allocator: std.mem.Allocator) !Arguments { var diag = clap.Diagnostic{}; - var args = clap.parse(clap.Help, ¶ms, .{ + var res = clap.parse(clap.Help, ¶ms, clap.parsers.default, .{ .diagnostic = &diag, .allocator = allocator, }) catch |err| { @@ -87,7 +87,7 @@ pub const Arguments = struct { return err; }; - var positionals = args.positionals(); + var positionals = res.positionals; var raw_args: std.ArrayListUnmanaged(string) = undefined; if (positionals.len > 0) { @@ -96,16 +96,16 @@ pub const Arguments = struct { raw_args = .{}; } - if (args.flag("--version")) { + if (res.args.version) { try Output.writer().writeAll(VERSION); Global.exit(0); } var method = Method.GET; var url: URL = .{}; - var body_string: string = args.option("--body") orelse ""; + var body_string: string = res.args.body orelse ""; - if (args.option("--file")) |file_path| { + if (res.args.file) |file_path| { if (file_path.len > 0) { var cwd = try std.process.getCwd(&cwd_buf); var parts = [_]string{file_path}; @@ -154,12 +154,12 @@ pub const Arguments = struct { return Arguments{ .url = url, .method = method, - .verbose = args.flag("--verbose"), + .verbose = res.args.verbose, .headers = .{}, .headers_buf = "", .body = body_string, - .turbo = args.flag("--turbo"), - .quiet = args.flag("--quiet"), + .turbo = res.args.turbo, + .quiet = res.args.quiet, }; } }; diff --git a/misctools/http_bench.zig b/misctools/http_bench.zig index 5e12f0157..d4d27b56e 100644 --- a/misctools/http_bench.zig +++ b/misctools/http_bench.zig @@ -82,7 +82,7 @@ pub const Arguments = struct { pub fn parse(allocator: std.mem.Allocator) !Arguments { var diag = clap.Diagnostic{}; - var args = clap.parse(clap.Help, ¶ms, .{ + var res = clap.parse(clap.Help, ¶ms, clap.parsers.default, .{ .diagnostic = &diag, .allocator = allocator, }) catch |err| { @@ -91,7 +91,7 @@ pub const Arguments = struct { return err; }; - var positionals = args.positionals(); + var positionals = res.positionals; var raw_args: std.ArrayListUnmanaged(string) = undefined; if (positionals.len > 0) { @@ -100,16 +100,16 @@ pub const Arguments = struct { raw_args = .{}; } - if (args.flag("--version")) { + if (res.args.version) { try Output.writer().writeAll(VERSION); Global.exit(0); } var method = Method.GET; var url: URL = .{}; - var body_string: string = args.option("--body") orelse ""; + var body_string: string = res.args.body orelse ""; - if (args.option("--file")) |file_path| { + if (res.args.file) |file_path| { if (file_path.len > 0) { var cwd = try std.process.getCwd(&cwd_buf); var parts = [_]string{file_path}; @@ -158,18 +158,18 @@ pub const Arguments = struct { return Arguments{ .url = url, .method = method, - .verbose = args.flag("--verbose"), + .verbose = res.args.verbose, .headers = .{}, .headers_buf = "", .body = body_string, - // .keep_alive = !args.flag("--no-keep-alive"), - .concurrency = std.fmt.parseInt(u16, args.option("--max-concurrency") orelse "32", 10) catch 32, - .turbo = args.flag("--turbo"), - .timeout = std.fmt.parseInt(usize, args.option("--timeout") orelse "0", 10) catch |err| { + // .keep_alive = !res.args.@"--no-keep-alive", + .concurrency = std.fmt.parseInt(u16, res.args.@"max-concurrency" orelse "32", 10) catch 32, + .turbo = res.args.turbo, + .timeout = std.fmt.parseInt(usize, res.args.timeout orelse "0", 10) catch |err| { Output.prettyErrorln("<r><red>{s}<r> parsing timeout", .{@errorName(err)}); Global.exit(1); }, - .count = std.fmt.parseInt(usize, args.option("--count") orelse "10", 10) catch |err| { + .count = std.fmt.parseInt(usize, res.args.count orelse "10", 10) catch |err| { Output.prettyErrorln("<r><red>{s}<r> parsing count", .{@errorName(err)}); Global.exit(1); }, |