authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-11-17 16:47:36-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-11-17 16:53:45-07:00
logaf4727814b4b5a28551fe47c40e31f6fdc91ccbe
tree63b4d8ab47888e08e038e63eb607c0d9ddc6957f
parent2eee0582f8654cb2b344ed8e2c43dcda3424dbe5

cli: make -h, --help consistent in usage text and parsing

also trivial fixes in the general usage text

1 files changed, 10 insertions(+), 10 deletions(-)

src/main.zig+10-10
...@@ -41,11 +41,11 @@ const usage =...@@ -41,11 +41,11 @@ const usage =
41 \\ build Build project from build.zig41 \\ build Build project from build.zig
42 \\ build-exe Create executable from source or object files42 \\ build-exe Create executable from source or object files
43 \\ build-lib Create library from source or object files43 \\ build-lib Create library from source or object files
44 \\ build-obj Create object from source or assembly44 \\ build-obj Create object from source or object files
45 \\ cc Use Zig as a drop-in C compiler45 \\ cc Use Zig as a drop-in C compiler
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, compiler id and version47 \\ env Print lib path, std path, cache directory, and version
48 \\ fmt Parse file and render in canonical zig format48 \\ fmt Reformat Zig source into canonical form
49 \\ init-exe Initialize a `zig build` application in the cwd49 \\ init-exe Initialize a `zig build` application in the cwd
50 \\ init-lib Initialize a `zig build` library in the cwd50 \\ init-lib Initialize a `zig build` library in the cwd
51 \\ libc Display native libc paths file or validate one51 \\ libc Display native libc paths file or validate one
...@@ -54,11 +54,11 @@ const usage =...@@ -54,11 +54,11 @@ const usage =
54 \\ targets List available compilation targets54 \\ targets List available compilation targets
55 \\ test Create and run a test build55 \\ test Create and run a test build
56 \\ version Print version number and exit56 \\ version Print version number and exit
57 \\ zen Print zen of zig and exit57 \\ zen Print Zen of Zig and exit
58 \\58 \\
59 \\General Options:59 \\General Options:
60 \\60 \\
61 \\ --help Print command-specific usage61 \\ -h, --help Print command-specific usage
62 \\62 \\
63;63;
6464
...@@ -2017,7 +2017,7 @@ pub fn cmdLibC(gpa: *Allocator, args: []const []const u8) !void {...@@ -2017,7 +2017,7 @@ pub fn cmdLibC(gpa: *Allocator, args: []const []const u8) !void {
2017 while (i < args.len) : (i += 1) {2017 while (i < args.len) : (i += 1) {
2018 const arg = args[i];2018 const arg = args[i];
2019 if (mem.startsWith(u8, arg, "-")) {2019 if (mem.startsWith(u8, arg, "-")) {
2020 if (mem.eql(u8, arg, "--help")) {2020 if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) {
2021 const stdout = io.getStdOut().writer();2021 const stdout = io.getStdOut().writer();
2022 try stdout.writeAll(usage_libc);2022 try stdout.writeAll(usage_libc);
2023 return cleanExit();2023 return cleanExit();
...@@ -2059,7 +2059,7 @@ pub const usage_init =...@@ -2059,7 +2059,7 @@ pub const usage_init =
2059 \\ directory.2059 \\ directory.
2060 \\2060 \\
2061 \\Options:2061 \\Options:
2062 \\ --help Print this help and exit2062 \\ -h, --help Print this help and exit
2063 \\2063 \\
2064 \\2064 \\
2065;2065;
...@@ -2148,7 +2148,7 @@ pub const usage_build =...@@ -2148,7 +2148,7 @@ pub const usage_build =
2148 \\ Build a project from build.zig.2148 \\ Build a project from build.zig.
2149 \\2149 \\
2150 \\Options:2150 \\Options:
2151 \\ --help Print this help and exit2151 \\ -h, --help Print this help and exit
2152 \\2152 \\
2153 \\2153 \\
2154;2154;
...@@ -2400,7 +2400,7 @@ pub const usage_fmt =...@@ -2400,7 +2400,7 @@ pub const usage_fmt =
2400 \\ recursively.2400 \\ recursively.
2401 \\2401 \\
2402 \\Options:2402 \\Options:
2403 \\ --help Print this help and exit2403 \\ -h, --help Print this help and exit
2404 \\ --color [auto|off|on] Enable or disable colored error messages2404 \\ --color [auto|off|on] Enable or disable colored error messages
2405 \\ --stdin Format code from stdin; output to stdout2405 \\ --stdin Format code from stdin; output to stdout
2406 \\ --check List non-conforming files and exit with an error2406 \\ --check List non-conforming files and exit with an error
...@@ -2432,7 +2432,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void {...@@ -2432,7 +2432,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void {
2432 while (i < args.len) : (i += 1) {2432 while (i < args.len) : (i += 1) {
2433 const arg = args[i];2433 const arg = args[i];
2434 if (mem.startsWith(u8, arg, "-")) {2434 if (mem.startsWith(u8, arg, "-")) {
2435 if (mem.eql(u8, arg, "--help")) {2435 if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) {
2436 const stdout = io.getStdOut().outStream();2436 const stdout = io.getStdOut().outStream();
2437 try stdout.writeAll(usage_fmt);2437 try stdout.writeAll(usage_fmt);
2438 return cleanExit();2438 return cleanExit();