authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-03-06 14:21:34-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-03-10 17:51:06-07:00
log33f3443243059ce7634dcddf8a87d6ed7837df06
tree1902f3583adce2694aeadd88eba97e2aedb2ffaf
parent0b1b3f02252ec92dc361480d7659d28eb685e610

add `zig std` subcommand


1 files changed, 15 insertions(+), 0 deletions(-)

src/main.zig+15
......@@ -98,6 +98,7 @@ const normal_usage =
9898 \\
9999 \\ env Print lib path, std path, cache directory, and version
100100 \\ help Print this help and exit
101 \\ std View standard library documentation in a browser
101102 \\ libc Display native libc paths file or validate one
102103 \\ targets List available compilation targets
103104 \\ version Print version number and exit
......@@ -309,6 +310,14 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
309310 .root_src_path = "libc.zig",
310311 .prepend_zig_lib_dir_path = true,
311312 });
313 } else if (mem.eql(u8, cmd, "std")) {
314 return jitCmd(gpa, arena, cmd_args, .{
315 .cmd_name = "std",
316 .root_src_path = "std-docs.zig",
317 .prepend_zig_lib_dir_path = true,
318 .prepend_zig_exe_path = true,
319 .prepend_global_cache_path = true,
320 });
312321 } else if (mem.eql(u8, cmd, "init")) {
313322 return cmdInit(gpa, arena, cmd_args);
314323 } else if (mem.eql(u8, cmd, "targets")) {
......@@ -5556,6 +5565,8 @@ const JitCmdOptions = struct {
55565565 cmd_name: []const u8,
55575566 root_src_path: []const u8,
55585567 prepend_zig_lib_dir_path: bool = false,
5568 prepend_global_cache_path: bool = false,
5569 prepend_zig_exe_path: bool = false,
55595570 depend_on_aro: bool = false,
55605571 capture: ?*[]u8 = null,
55615572};
......@@ -5714,6 +5725,10 @@ fn jitCmd(
57145725
57155726 if (options.prepend_zig_lib_dir_path)
57165727 child_argv.appendAssumeCapacity(zig_lib_directory.path.?);
5728 if (options.prepend_zig_exe_path)
5729 child_argv.appendAssumeCapacity(self_exe_path);
5730 if (options.prepend_global_cache_path)
5731 child_argv.appendAssumeCapacity(global_cache_directory.path.?);
57175732
57185733 child_argv.appendSliceAssumeCapacity(args);
57195734