authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2020-11-18 13:58:27+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-11-18 17:37:14-07:00
log8af0a1987b940732b13b6d4c4e33c00637f69dd5
treef03822d6bb094cbf7d85ba28a1d192e39a25aa4c
parentb498d26376cc46481f06f09f5f8eaf32ce81801f

make help in commands more consistent

Closes #7101 Co-authored-by: pfg <pfg@pfg.pw>

2 files changed, 4 insertions(+), 3 deletions(-)

lib/std/special/build_runner.zig+2-2
...@@ -69,7 +69,7 @@ pub fn main() !void {...@@ -69,7 +69,7 @@ pub fn main() !void {
69 } else if (mem.startsWith(u8, arg, "-")) {69 } else if (mem.startsWith(u8, arg, "-")) {
70 if (mem.eql(u8, arg, "--verbose")) {70 if (mem.eql(u8, arg, "--verbose")) {
71 builder.verbose = true;71 builder.verbose = true;
72 } else if (mem.eql(u8, arg, "--help")) {72 } else if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) {
73 return usage(builder, false, stdout_stream);73 return usage(builder, false, stdout_stream);
74 } else if (mem.eql(u8, arg, "--prefix")) {74 } else if (mem.eql(u8, arg, "--prefix")) {
75 builder.install_prefix = nextArg(args, &arg_idx) orelse {75 builder.install_prefix = nextArg(args, &arg_idx) orelse {
...@@ -176,7 +176,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void...@@ -176,7 +176,7 @@ fn usage(builder: *Builder, already_ran_build: bool, out_stream: anytype) !void
176 try out_stream.writeAll(176 try out_stream.writeAll(
177 \\177 \\
178 \\General Options:178 \\General Options:
179 \\ --help Print this help and exit179 \\ -h, --help Print this help and exit
180 \\ --verbose Print commands before executing them180 \\ --verbose Print commands before executing them
181 \\ --prefix [path] Override default install prefix181 \\ --prefix [path] Override default install prefix
182 \\ --search-prefix [path] Add a path to look for binaries, libraries, headers182 \\ --search-prefix [path] Add a path to look for binaries, libraries, headers
src/main.zig+2-1
...@@ -46,6 +46,7 @@ const usage =...@@ -46,6 +46,7 @@ const usage =
46 \\ c++ Use Zig as a drop-in C++ compiler46 \\ c++ Use Zig as a drop-in C++ compiler
47 \\ env Print lib path, std path, cache directory, and version47 \\ env Print lib path, std path, cache directory, and version
48 \\ fmt Reformat Zig source into canonical form48 \\ fmt Reformat Zig source into canonical form
49 \\ help Print this help and exit
49 \\ init-exe Initialize a `zig build` application in the cwd50 \\ init-exe Initialize a `zig build` application in the cwd
50 \\ init-lib Initialize a `zig build` library in the cwd51 \\ init-lib Initialize a `zig build` library in the cwd
51 \\ libc Display native libc paths file or validate one52 \\ libc Display native libc paths file or validate one
...@@ -195,7 +196,7 @@ pub fn mainArgs(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v...@@ -195,7 +196,7 @@ pub fn mainArgs(gpa: *Allocator, arena: *Allocator, args: []const []const u8) !v
195 try @import("print_env.zig").cmdEnv(arena, cmd_args, io.getStdOut().outStream());196 try @import("print_env.zig").cmdEnv(arena, cmd_args, io.getStdOut().outStream());
196 } else if (mem.eql(u8, cmd, "zen")) {197 } else if (mem.eql(u8, cmd, "zen")) {
197 try io.getStdOut().writeAll(info_zen);198 try io.getStdOut().writeAll(info_zen);
198 } else if (mem.eql(u8, cmd, "help")) {199 } else if (mem.eql(u8, cmd, "help") or mem.eql(u8, cmd, "-h") or mem.eql(u8, cmd, "--help")) {
199 try io.getStdOut().writeAll(usage);200 try io.getStdOut().writeAll(usage);
200 } else {201 } else {
201 std.log.info("{}", .{usage});202 std.log.info("{}", .{usage});