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 =...@@ -98,6 +98,7 @@ const normal_usage =
98 \\98 \\
99 \\ env Print lib path, std path, cache directory, and version99 \\ env Print lib path, std path, cache directory, and version
100 \\ help Print this help and exit100 \\ help Print this help and exit
101 \\ std View standard library documentation in a browser
101 \\ libc Display native libc paths file or validate one102 \\ libc Display native libc paths file or validate one
102 \\ targets List available compilation targets103 \\ targets List available compilation targets
103 \\ version Print version number and exit104 \\ version Print version number and exit
...@@ -309,6 +310,14 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {...@@ -309,6 +310,14 @@ fn mainArgs(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
309 .root_src_path = "libc.zig",310 .root_src_path = "libc.zig",
310 .prepend_zig_lib_dir_path = true,311 .prepend_zig_lib_dir_path = true,
311 });312 });
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 });
312 } else if (mem.eql(u8, cmd, "init")) {321 } else if (mem.eql(u8, cmd, "init")) {
313 return cmdInit(gpa, arena, cmd_args);322 return cmdInit(gpa, arena, cmd_args);
314 } else if (mem.eql(u8, cmd, "targets")) {323 } else if (mem.eql(u8, cmd, "targets")) {
...@@ -5556,6 +5565,8 @@ const JitCmdOptions = struct {...@@ -5556,6 +5565,8 @@ const JitCmdOptions = struct {
5556 cmd_name: []const u8,5565 cmd_name: []const u8,
5557 root_src_path: []const u8,5566 root_src_path: []const u8,
5558 prepend_zig_lib_dir_path: bool = false,5567 prepend_zig_lib_dir_path: bool = false,
5568 prepend_global_cache_path: bool = false,
5569 prepend_zig_exe_path: bool = false,
5559 depend_on_aro: bool = false,5570 depend_on_aro: bool = false,
5560 capture: ?*[]u8 = null,5571 capture: ?*[]u8 = null,
5561};5572};
...@@ -5714,6 +5725,10 @@ fn jitCmd(...@@ -5714,6 +5725,10 @@ fn jitCmd(
57145725
5715 if (options.prepend_zig_lib_dir_path)5726 if (options.prepend_zig_lib_dir_path)
5716 child_argv.appendAssumeCapacity(zig_lib_directory.path.?);5727 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
5718 child_argv.appendSliceAssumeCapacity(args);5733 child_argv.appendSliceAssumeCapacity(args);
57195734