Skip to content

Commit e2ab2df

Browse files
committed
add cli usage for zon and json commands
1 parent d72ef35 commit e2ab2df

1 file changed

Lines changed: 26 additions & 2 deletions

File tree

src/zigpkg.zig

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ const usage =
2626
\\
2727
\\environment variables:
2828
\\
29-
\\ ZIG: path to the zig compiler to invoke in subprocesses. defaults to "zig".
29+
\\ ZIG: path to the zig compiler to invoke in subprocesses.
30+
\\ defaults to "zig" in the PATH.
3031
\\
3132
\\
3233
;
@@ -173,7 +174,7 @@ pub fn cmd_deppkg(opt: GlobalOptions, args: []const []const u8) !u8 {
173174
pub fn helpArg(args: []const []const u8) bool {
174175
for (args) |arg| {
175176
if (std.mem.eql(u8, arg, "--")) break;
176-
inline for (&.{ "--help", "-h", "-?" }) |helparg| {
177+
inline for (&.{ "--help", "-h", "-?", "--usage", "help", "-help" }) |helparg| {
177178
if (std.ascii.eqlIgnoreCase(arg, helparg)) return true;
178179
}
179180
}
@@ -308,6 +309,7 @@ pub fn cmd_from_zon(opt: GlobalOptions, args: []const []const u8) !u8 {
308309

309310
pub fn cmd_dot(opt: GlobalOptions, args: []const []const u8) !u8 {
310311
const cmd_usage =
312+
\\
311313
\\usage: zigpkg dot {--help|build_root_path|--} [zig args]
312314
\\
313315
\\rerun "zig build" and output a graphviz ".dot" file of all build steps
@@ -401,6 +403,17 @@ pub fn cmd_dothtml(opt: GlobalOptions, args: []const []const u8) !u8 {
401403
}
402404

403405
pub fn cmd_json(opt: GlobalOptions, args: []const []const u8) !u8 {
406+
if (helpArg(args[0..@min(1, args.len)])) {
407+
try opt.stdout.writeAll(
408+
\\
409+
\\usage: zigpkg json {path to build root} [--] [arguments to zig build]
410+
\\
411+
\\rerun "zig build" with a custom build runner and output the build graph as .json to stdout
412+
\\
413+
\\
414+
);
415+
return 0;
416+
}
404417
const b = try zonOutputCmd(opt, args);
405418
defer b.deinit(opt.gpa);
406419

@@ -413,6 +426,17 @@ pub fn cmd_json(opt: GlobalOptions, args: []const []const u8) !u8 {
413426
}
414427

415428
pub fn cmd_zon(opt: GlobalOptions, args: []const []const u8) !u8 {
429+
if (helpArg(args[0..@min(1, args.len)])) {
430+
try opt.stdout.writeAll(
431+
\\
432+
\\usage: zigpkg zon {path to build root} [--] [arguments to zig build]
433+
\\
434+
\\rerun "zig build" with a custom build runner and output the build graph as .zon to stdout
435+
\\
436+
\\
437+
);
438+
return 0;
439+
}
416440
const b = try zonOutputCmd(opt, args);
417441
defer b.deinit(opt.gpa);
418442

0 commit comments

Comments
 (0)