Skip to content

Commit 13d2b98

Browse files
committed
help improvements
1 parent 217e546 commit 13d2b98

4 files changed

Lines changed: 30 additions & 11 deletions

File tree

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,21 @@ inside this tool.
2323
> zig build zigpkg -- --help
2424
usage: zigpkg <subcommand> [--help]
2525
26-
stores all dependencies of a directory containing build.zig.zon in a .tar.gz archive
26+
a multicall too to work with zig's build graphs
2727
2828
available subcommands:
2929
dot rerun "zig build" and output a graphviz ".dot" file of build steps based on args
3030
dotall rerun "zig build" and output a graphviz ".dot" file of all build steps
31+
dothtml "dotall", but output html for vis.js instead of ".dit"
3132
zon rerun "zig build" with a custom build runner and output the build graph as .zon to stdout
3233
json same as "zon" but output json
33-
deppkg more subcommands for creating and working with "deppkg.tar.gz" files storing all
34-
dependencies required to build a zig package
34+
deppkg more subcommands for creating and working with "deppkg.tar.gz" files. storing all
35+
stores all dependencies of a directory containing build.zig.zon in a .tar.gz archive
3536
3637
environment variables:
3738
38-
ZIG: path to the zig compiler to invoke in subprocesses. defaults to "zig".
39-
39+
ZIG: path to the zig compiler to invoke in subprocesses.
40+
defaults to "zig" in the PATH.
4041
```
4142

4243
## Dependency packages

src/runner-zig.zig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
const std = @import("std");
22
const builtin = @import("builtin");
33

4-
const later_than_zig_15 = builtin.zig_version.order(std.SemanticVersion.parse("0.15.99") catch unreachable) == .gt;
4+
// changes to readFileAllocOptions after this
5+
const later_than_zig_15 = std.mem.containsAtLeastScalar(std.math.Order, &.{
6+
.gt,
7+
.eq,
8+
}, 1, builtin.zig_version.order(
9+
std.SemanticVersion.parse("0.16.0") catch unreachable,
10+
));
511

612
pub const runner = if (later_than_zig_15)
713
// 0.16.0-dev.1354+94e98bfe8

src/zigpkg.zig

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ const viz_network = @import("viz_network.html.zig").viz_network;
1313
const usage =
1414
\\usage: zigpkg <subcommand> [--help]
1515
\\
16-
\\stores all dependencies of a directory containing build.zig.zon in a .tar.gz archive
16+
\\a multicall too to work with zig's build graphs
1717
\\
1818
\\available subcommands:
1919
\\ dot rerun "zig build" and output a graphviz ".dot" file of build steps based on args
2020
\\ dotall rerun "zig build" and output a graphviz ".dot" file of all build steps
2121
\\ dothtml "dotall", but output html for vis.js instead of ".dit"
2222
\\ zon rerun "zig build" with a custom build runner and output the build graph as .zon to stdout
2323
\\ json same as "zon" but output json
24-
\\ deppkg more subcommands for creating and working with "deppkg.tar.gz" files storing all
25-
\\ dependencies required to build a zig package
24+
\\ deppkg more subcommands for creating and working with "deppkg.tar.gz" files. storing all
25+
\\ stores all dependencies of a directory containing build.zig.zon in a .tar.gz archive
2626
\\
2727
\\environment variables:
2828
\\
@@ -205,14 +205,21 @@ pub fn cmd_extract(opt: GlobalOptions, args: []const []const u8) !u8 {
205205

206206
pub fn cmd_create(opt: GlobalOptions, args: []const []const u8) !u8 {
207207
const cmd_usage =
208+
\\
208209
\\usage: zigpkg create <deppkg.tar.gz> <<build root path>|--> [z]
209210
\\
211+
\\
210212
;
211213
if (args.len < 1) {
212214
try opt.stdout.writeAll(cmd_usage);
213215
return 1;
214216
}
215217

218+
if (helpArg(args[0..@min(1, args.len)])) {
219+
try opt.stdout.writeAll(cmd_usage);
220+
return 1;
221+
}
222+
216223
const output = try std.fs.path.resolve(opt.gpa, &.{ opt.cwd, args[0] });
217224
defer opt.gpa.free(output);
218225

src/zonparse.zig

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,12 @@ const builtin = @import("builtin");
1919
const zig_15_or_later = builtin.zig_version.order(std.SemanticVersion.parse("0.14.99") catch unreachable) == .gt;
2020

2121
// changes to readFileAllocOptions after this
22-
const later_than_zig_15_1 = builtin.zig_version.order(std.SemanticVersion.parse("0.15.99") catch unreachable) == .gt;
22+
const later_than_zig_15 = std.mem.containsAtLeastScalar(std.math.Order, &.{
23+
.gt,
24+
.eq,
25+
}, 1, builtin.zig_version.order(
26+
std.SemanticVersion.parse("0.16.0") catch unreachable,
27+
));
2328

2429
pub const zonparse = @import("zonparse-master.zig");
2530

@@ -36,7 +41,7 @@ pub fn cwdReadFileAllocZ(
3641
max_bytes: usize,
3742
) ![:0]const u8 {
3843
const cwd = std.fs.cwd();
39-
if (comptime later_than_zig_15_1) {
44+
if (comptime later_than_zig_15) {
4045
return cwd.readFileAllocOptions(
4146
subpath,
4247
allocator,

0 commit comments

Comments
 (0)