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:54:15-07:00
logeea4cd2924edcade85b77879384738d5593bbff5
treed63a96d94a4e633092993012bd89ab90466a3779
parent4d44a813dea076196d2de8d2a672924f82ff137f

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
...@@ -2020,7 +2020,7 @@ pub fn cmdLibC(gpa: *Allocator, args: []const []const u8) !void {...@@ -2020,7 +2020,7 @@ pub fn cmdLibC(gpa: *Allocator, args: []const []const u8) !void {
2020 while (i < args.len) : (i += 1) {2020 while (i < args.len) : (i += 1) {
2021 const arg = args[i];2021 const arg = args[i];
2022 if (mem.startsWith(u8, arg, "-")) {2022 if (mem.startsWith(u8, arg, "-")) {
2023 if (mem.eql(u8, arg, "--help")) {2023 if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) {
2024 const stdout = io.getStdOut().writer();2024 const stdout = io.getStdOut().writer();
2025 try stdout.writeAll(usage_libc);2025 try stdout.writeAll(usage_libc);
2026 return cleanExit();2026 return cleanExit();
...@@ -2062,7 +2062,7 @@ pub const usage_init =...@@ -2062,7 +2062,7 @@ pub const usage_init =
2062 \\ directory.2062 \\ directory.
2063 \\2063 \\
2064 \\Options:2064 \\Options:
2065 \\ --help Print this help and exit2065 \\ -h, --help Print this help and exit
2066 \\2066 \\
2067 \\2067 \\
2068;2068;
...@@ -2151,7 +2151,7 @@ pub const usage_build =...@@ -2151,7 +2151,7 @@ pub const usage_build =
2151 \\ Build a project from build.zig.2151 \\ Build a project from build.zig.
2152 \\2152 \\
2153 \\Options:2153 \\Options:
2154 \\ --help Print this help and exit2154 \\ -h, --help Print this help and exit
2155 \\2155 \\
2156 \\2156 \\
2157;2157;
...@@ -2403,7 +2403,7 @@ pub const usage_fmt =...@@ -2403,7 +2403,7 @@ pub const usage_fmt =
2403 \\ recursively.2403 \\ recursively.
2404 \\2404 \\
2405 \\Options:2405 \\Options:
2406 \\ --help Print this help and exit2406 \\ -h, --help Print this help and exit
2407 \\ --color [auto|off|on] Enable or disable colored error messages2407 \\ --color [auto|off|on] Enable or disable colored error messages
2408 \\ --stdin Format code from stdin; output to stdout2408 \\ --stdin Format code from stdin; output to stdout
2409 \\ --check List non-conforming files and exit with an error2409 \\ --check List non-conforming files and exit with an error
...@@ -2435,7 +2435,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void {...@@ -2435,7 +2435,7 @@ pub fn cmdFmt(gpa: *Allocator, args: []const []const u8) !void {
2435 while (i < args.len) : (i += 1) {2435 while (i < args.len) : (i += 1) {
2436 const arg = args[i];2436 const arg = args[i];
2437 if (mem.startsWith(u8, arg, "-")) {2437 if (mem.startsWith(u8, arg, "-")) {
2438 if (mem.eql(u8, arg, "--help")) {2438 if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) {
2439 const stdout = io.getStdOut().outStream();2439 const stdout = io.getStdOut().outStream();
2440 try stdout.writeAll(usage_fmt);2440 try stdout.writeAll(usage_fmt);
2441 return cleanExit();2441 return cleanExit();