diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-03-06 14:21:34 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-03-10 17:51:06 -0700 |
| commit | 33f3443243059ce7634dcddf8a87d6ed7837df06 (patch) | |
| tree | 1902f3583adce2694aeadd88eba97e2aedb2ffaf /src/main.zig | |
| parent | 0b1b3f02252ec92dc361480d7659d28eb685e610 (diff) | |
| download | zig-33f3443243059ce7634dcddf8a87d6ed7837df06.tar.gz zig-33f3443243059ce7634dcddf8a87d6ed7837df06.zip | |
add `zig std` subcommand
Diffstat (limited to 'src/main.zig')
| -rw-r--r-- | src/main.zig | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/main.zig b/src/main.zig index 05c9149b53..5a187c65e9 100644 --- a/src/main.zig +++ b/src/main.zig @@ -98,6 +98,7 @@ const normal_usage = \\ \\ env Print lib path, std path, cache directory, and version \\ help Print this help and exit + \\ std View standard library documentation in a browser \\ libc Display native libc paths file or validate one \\ targets List available compilation targets \\ version Print version number and exit @@ -309,6 +310,14 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { .root_src_path = "libc.zig", .prepend_zig_lib_dir_path = true, }); + } else if (mem.eql(u8, cmd, "std")) { + return jitCmd(gpa, arena, cmd_args, .{ + .cmd_name = "std", + .root_src_path = "std-docs.zig", + .prepend_zig_lib_dir_path = true, + .prepend_zig_exe_path = true, + .prepend_global_cache_path = true, + }); } else if (mem.eql(u8, cmd, "init")) { return cmdInit(gpa, arena, cmd_args); } else if (mem.eql(u8, cmd, "targets")) { @@ -5556,6 +5565,8 @@ const JitCmdOptions = struct { cmd_name: []const u8, root_src_path: []const u8, prepend_zig_lib_dir_path: bool = false, + prepend_global_cache_path: bool = false, + prepend_zig_exe_path: bool = false, depend_on_aro: bool = false, capture: ?*[]u8 = null, }; @@ -5714,6 +5725,10 @@ fn jitCmd( if (options.prepend_zig_lib_dir_path) child_argv.appendAssumeCapacity(zig_lib_directory.path.?); + if (options.prepend_zig_exe_path) + child_argv.appendAssumeCapacity(self_exe_path); + if (options.prepend_global_cache_path) + child_argv.appendAssumeCapacity(global_cache_directory.path.?); child_argv.appendSliceAssumeCapacity(args); |
