diff options
author | 2023-09-28 22:35:47 -0700 | |
---|---|---|
committer | 2023-10-12 16:02:34 -0700 | |
commit | 3cd555210cae15d39e5b615a79f1ecad9de71861 (patch) | |
tree | 93b6db448f250a2b584a3b8f5e15bb262bb46233 | |
parent | 892593c73b93bd5c0d4a9211c08646729f22f034 (diff) | |
download | bun-3cd555210cae15d39e5b615a79f1ecad9de71861.tar.gz bun-3cd555210cae15d39e5b615a79f1ecad9de71861.tar.zst bun-3cd555210cae15d39e5b615a79f1ecad9de71861.zip |
WIP
-rw-r--r-- | src/cli.zig | 14 | ||||
-rw-r--r-- | src/deps/zig-clap/clap.zig | 5 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/cli.zig b/src/cli.zig index a05fb3768..46b758a9b 100644 --- a/src/cli.zig +++ b/src/cli.zig @@ -95,6 +95,7 @@ pub const Cli = struct { }, else => { // Always dump the logs + // std.debug.print("dump logs", .{}); if (Output.enable_ansi_colors_stderr) { log.printForLogLevelWithEnableAnsiColors(Output.errorWriter(), true) catch {}; } else { @@ -375,6 +376,7 @@ pub const Arguments = struct { } pub fn parse(allocator: std.mem.Allocator, ctx: *Command.Context, comptime cmd: Command.Tag) !Api.TransformOptions { + std.debug.print("starting parse\n", .{}); var diag = clap.Diagnostic{}; const params_to_use = comptime cmd.params(); @@ -386,13 +388,17 @@ pub const Arguments = struct { else 0, }) catch |err| { + std.debug.print("error caught\n", .{}); // Report useful error and exit clap.help(Output.errorWriter(), params_to_use) catch {}; Output.errorWriter().writeAll("\n") catch {}; diag.report(Output.errorWriter(), err) catch {}; + std.debug.print("done printing\n", .{}); Global.exit(1); }; + std.debug.print("past parsing\n", .{}); + if (args.flag("--version")) { printVersionAndExit(); } @@ -529,6 +535,7 @@ pub const Arguments = struct { opts.no_summary = args.flag("--no-summary"); if (cmd == .AutoCommand or cmd == .RunCommand or cmd == .TestCommand) { + std.debug.print("autocommand\n", .{}); const preloads = args.options("--preload"); if (ctx.preloads.len > 0 and preloads.len > 0) { var all = std.ArrayList(string).initCapacity(ctx.allocator, ctx.preloads.len + preloads.len) catch unreachable; @@ -578,7 +585,9 @@ pub const Arguments = struct { } const print_help = args.flag("--help"); + if (print_help) { + std.debug.print("printing help\n", .{}); clap.help(Output.writer(), params_to_use[0..params_to_use.len]) catch {}; Output.prettyln("\n-------\n\n", .{}); Output.flush(); @@ -1076,7 +1085,10 @@ pub const Command = struct { ctx.allocator = allocator; if (comptime Command.Tag.uses_global_options.get(command)) { + std.debug.print("arguments.parse\n", .{}); ctx.args = try Arguments.parse(allocator, &ctx, command); + } else { + std.debug.print("doesnt use global options\n", .{}); } return ctx; @@ -1578,6 +1590,7 @@ pub const Command = struct { var ctx = Command.Context.create(allocator, log, .AutoCommand) catch |e| { switch (e) { error.MissingEntryPoint => { + std.debug.print("missing entry point\n", .{}); HelpCommand.execWithReason(allocator, .explicit); return; }, @@ -1685,6 +1698,7 @@ pub const Command = struct { Global.exit(1); } + std.debug.print("fallback to help\n", .{}); try HelpCommand.exec(allocator); }, else => unreachable, diff --git a/src/deps/zig-clap/clap.zig b/src/deps/zig-clap/clap.zig index 37cc4814e..af21823b9 100644 --- a/src/deps/zig-clap/clap.zig +++ b/src/deps/zig-clap/clap.zig @@ -209,6 +209,7 @@ pub const Diagnostic = struct { /// Default diagnostics reporter when all you want is English with no colors. /// Use this as a reference for implementing your own if needed. pub fn report(diag: Diagnostic, stream: anytype, err: anyerror) !void { + std.debug.print("starting diag report", .{}); const Arg = struct { prefix: []const u8, name: []const u8, @@ -220,6 +221,7 @@ pub const Diagnostic = struct { else Arg{ .prefix = "", .name = diag.arg }; + std.debug.print("switching in diag.report", .{}); switch (err) { error.DoesntTakeValue => try stream.print("The argument '{s}{s}' does not take a value\n", .{ a.prefix, a.name }), error.MissingValue => try stream.print("The argument '{s}{s}' requires a value but none was supplied\n", .{ a.prefix, a.name }), @@ -229,6 +231,9 @@ pub const Diagnostic = struct { try stream.print("Failed to parse argument due to unexpected single dash\n", .{}), else => try stream.print("Error while parsing arguments: {s}\n", .{@errorName(err)}), } + + // print error + } }; |