aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Colin McDonnell <colinmcd94@gmail.com> 2023-10-10 00:18:57 -0700
committerGravatar Colin McDonnell <colinmcd94@gmail.com> 2023-10-12 16:04:25 -0700
commit6180b2dc2afec4a8c8ad9e8462301b8c8d089199 (patch)
tree5b567a7b90854b29710960aac259dcadeacd242b
parent07db922aad3b043a0b1826019e356b9e09c8d27b (diff)
downloadbun-6180b2dc2afec4a8c8ad9e8462301b8c8d089199.tar.gz
bun-6180b2dc2afec4a8c8ad9e8462301b8c8d089199.tar.zst
bun-6180b2dc2afec4a8c8ad9e8462301b8c8d089199.zip
WIP
-rw-r--r--package.json8
-rw-r--r--src/cli.zig76
-rw-r--r--src/deps/zig-clap/clap/comptime.zig3
-rw-r--r--src/deps/zig-clap/clap/streaming.zig4
4 files changed, 14 insertions, 77 deletions
diff --git a/package.json b/package.json
index f74c6a1d1..623f230cd 100644
--- a/package.json
+++ b/package.json
@@ -29,11 +29,5 @@
"bun-webkit": "0.0.1-acc1e092b4758a712998d462ee54c52e75e71780"
},
"version": "0.0.0",
- "prettier": "./.prettierrc.cjs",
- "name": "core",
- "module": "index.ts",
- "type": "module",
- "peerDependencies": {
- "typescript": "^5.0.0"
- }
+ "prettier": "./.prettierrc.cjs"
}
diff --git a/src/cli.zig b/src/cli.zig
index 807d8568f..24b46d052 100644
--- a/src/cli.zig
+++ b/src/cli.zig
@@ -182,29 +182,6 @@ pub const Arguments = struct {
clap.parseParam("-b, --bun Force a script or package to use Bun's runtime instead of Node.js (via symlinking node)") catch unreachable,
};
- // these commands don't use clap
- // Command.Tag.BunxCommand
- // Command.Tag.InitCommand
- // Command.Tag.CreateCommand
- // Command.Tag.DiscordCommand
- // Command.Tag.GetCompletionsCommand
- // Command.Tag.HelpCommand
- // Command.Tag.InstallCompletionsCommand
- // Command.Tag.PackageManagerCommand
- // Command.Tag.UpgradeCommand
- // Command.Tag.ReplCommand
- // Command.Tag.ReservedCommand
-
- // const public_params = runtime_params_ ++ auto_install_params;
-
- // these were only used in bun dev
- // const debug_params = [_]ParamType{
- // clap.parseParam("--dump-environment-variables Dump environment variables from .env and process as JSON and quit. Useful for debugging") catch unreachable,
- // clap.parseParam("--dump-limits Dump system limits. Useful for debugging") catch unreachable,
- // };
-
- // pub const params = public_params ++ debug_params;
-
const build_only_params = [_]ParamType{
clap.parseParam("--format <STR> Specifies the module format to build to. Only esm is supported.") catch unreachable,
clap.parseParam("--target <STR> The intended execution environment for the bundle. \"browser\", \"bun\" or \"node\"") catch unreachable,
@@ -231,14 +208,14 @@ pub const Arguments = struct {
// TODO: update test completions
const test_only_params = [_]ParamType{
- clap.parseParam("--timeout <NUMBER>") catch unreachable,
- clap.parseParam("--update-snapshots") catch unreachable,
- clap.parseParam("--rerun-each <NUMBER>") catch unreachable,
- clap.parseParam("--only") catch unreachable,
- clap.parseParam("--todo") catch unreachable,
- clap.parseParam("--coverage") catch unreachable,
- clap.parseParam("--bail <NUMBER>?") catch unreachable,
- clap.parseParam("-t, --test-name-pattern <STR>") catch unreachable,
+ clap.parseParam("--timeout <NUMBER> Set the per-test timeout in milliseconds, default is 5000.") catch unreachable,
+ clap.parseParam("--update-snapshots Update snapshot files") catch unreachable,
+ clap.parseParam("--rerun-each <NUMBER> Re-run each test file <NUMBER> times, helps catch certain bugs") catch unreachable,
+ clap.parseParam("--only Only run tests that are marked with \"test.only()\"") catch unreachable,
+ clap.parseParam("--todo Include tests that are marked with \"test.todo()\"") catch unreachable,
+ clap.parseParam("--coverage Generate a coverage profile") catch unreachable,
+ clap.parseParam("--bail <NUMBER>? Exit the test suite after <NUMBER> failures. If you do not specify a number, it defaults to 1.") catch unreachable,
+ clap.parseParam("-t, --test-name-pattern <STR> Run only tests with a name that matches the given regex.") catch unreachable,
};
pub const test_params = test_only_params ++ runtime_params_ ++ transpiler_params_ ++ base_params_;
@@ -607,6 +584,7 @@ pub const Arguments = struct {
opts.origin = try std.fmt.allocPrint(allocator, "http://localhost:{d}/", .{opts.port.?});
}
+ // these we're only used in bun dev
// ctx.debug.dump_environment_variables = args.flag("--dump-environment-variables");
// ctx.debug.dump_limits = args.flag("--dump-limits");
@@ -1688,9 +1666,8 @@ pub const Command = struct {
Global.exit(1);
}
- // Output.prettyWarnln("<r><yellow>warn<r><d>:<r> failed to parse command\n", .{});
-
- // Output.flush();
+ Output.prettyWarnln("<r><yellow>warn<r><d>:<r> failed to parse command\n", .{});
+ Output.flush();
try HelpCommand.exec(allocator);
},
}
@@ -1803,34 +1780,7 @@ pub const Command = struct {
};
}
- // pub fn params_to_print(comptime cmd: Tag) []const Arguments.ParamType {
- // return &comptime switch (cmd) {
- // .BuildCommand => Arguments.build_only_params,
- // .TestCommand => Arguments.test_only_params,
- // .InstallCommand => Install.PackageManager.install_params,
- // .AddCommand => Install.PackageManager.add_params,
- // .UpdateCommand => Install.PackageManager.update_params,
- // .RemoveCommand => Install.PackageManager.remove_params,
- // .LinkCommand => Install.PackageManager.link_params,
- // .UnlinkCommand => Install.PackageManager.unlink_params,
- // .AutoCommand => Arguments.auto_params,
- // .RunCommand => Arguments.run_params,
- // .BunxCommand => Arguments.runtime_params_ ++ Arguments.transpiler_params_,
- // .InitCommand => Arguments.runtime_params_ ++ Arguments.transpiler_params_,
- // .CreateCommand => Arguments.runtime_params_ ++ Arguments.transpiler_params_,
- // .DiscordCommand => Arguments.runtime_params_ ++ Arguments.transpiler_params_,
- // .GetCompletionsCommand => Arguments.runtime_params_ ++ Arguments.transpiler_params_,
- // .HelpCommand => Arguments.runtime_params_ ++ Arguments.transpiler_params_,
- // .InstallCompletionsCommand => Arguments.runtime_params_ ++ Arguments.transpiler_params_,
- // .PackageManagerCommand => Arguments.runtime_params_ ++ Arguments.transpiler_params_,
- // .UpgradeCommand => Arguments.runtime_params_ ++ Arguments.transpiler_params_,
- // .ReplCommand => Arguments.runtime_params_ ++ Arguments.transpiler_params_,
- // .ReservedCommand => Arguments.runtime_params_ ++ Arguments.transpiler_params_,
- // };
- // }
-
pub fn printHelp(comptime cmd: Tag) void {
- // const params_list = comptime cmd.params_to_print();
switch (cmd) {
// these commands do not use Context
@@ -1970,7 +1920,7 @@ pub const Command = struct {
Output.pretty("\n", .{});
Output.pretty(intro_text, .{});
Output.flush();
- Output.pretty("\n<b>Flags:<r>", .{});
+ Output.pretty("\n\n<b>Flags:<r>", .{});
Output.flush();
clap.simpleHelp(&Arguments.test_only_params);
Output.pretty("\n\n", .{});
@@ -2012,7 +1962,7 @@ pub const Command = struct {
Output.pretty("\n", .{});
Output.pretty(intro_text, .{});
Output.flush();
- Output.pretty("\n<b>Flags:<r>", .{});
+ Output.pretty("\n\n<b>Flags:<r>", .{});
Output.flush();
clap.simpleHelp(&Arguments.test_only_params);
Output.pretty("\n\n", .{});
diff --git a/src/deps/zig-clap/clap/comptime.zig b/src/deps/zig-clap/clap/comptime.zig
index a890ee4e2..d32a60f11 100644
--- a/src/deps/zig-clap/clap/comptime.zig
+++ b/src/deps/zig-clap/clap/comptime.zig
@@ -74,9 +74,6 @@ pub fn ComptimeClap(
while (try stream.next()) |arg| {
const param = arg.param;
- // std.debug.print("arg: {s}\n", .{arg.value orelse "~null~"});
- // std.debug.print("arg: {s}\n", .{arg.param.names.long orelse arg.param.names.short orelse "~noname~"});
- // std.debug.print("state: {s}\n", .{@tagName(stream.state)});
if (param.names.long == null and param.names.short == null) {
try pos.append(arg.value.?);
if (opt.stop_after_positional_at > 0 and pos.items.len >= opt.stop_after_positional_at) {
diff --git a/src/deps/zig-clap/clap/streaming.zig b/src/deps/zig-clap/clap/streaming.zig
index 0e5d24ad8..ffe75b1cc 100644
--- a/src/deps/zig-clap/clap/streaming.zig
+++ b/src/deps/zig-clap/clap/streaming.zig
@@ -59,13 +59,10 @@ pub fn StreamingClap(comptime Id: type, comptime ArgIterator: type) type {
}
fn normal(parser: *@This()) ArgError!?Arg(Id) {
- std.debug.print("normal()\n", .{});
const ArgType = Arg(Id);
const arg_info = (try parser.parseNextArg()) orelse return null;
const arg = arg_info.arg;
- std.debug.print("arg: {s}:{s}\n", .{ arg, @tagName(arg_info.kind) });
-
switch (arg_info.kind) {
.long => {
const eql_index = mem.indexOfScalar(u8, arg, '=');
@@ -121,7 +118,6 @@ pub fn StreamingClap(comptime Id: type, comptime ArgIterator: type) type {
// interpret the rest of the arguments as positional
// arguments.
if (mem.eql(u8, arg, "--")) {
- std.debug.print("rest are positional\n", .{});
parser.state = .rest_are_positional;
// return null to terminate arg parsing
const value = parser.iter.next() orelse return null;