Skip to content

Commit

Permalink
Add usage command to CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
michidk committed Dec 28, 2023
1 parent 1001802 commit e55f664
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/opts.zig
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ pub fn parse(alloc: std.mem.Allocator) !?Opts {
// CLI Parameters
const params = comptime clap.parseParamsComptime(
\\-h, --help Display this help.
\\-u, --usage Displays a short command usage
\\<str> The telnet URI to connect to.
\\
);
Expand All @@ -61,6 +62,9 @@ pub fn parse(alloc: std.mem.Allocator) !?Opts {
if (res.args.help != 0) {
try clap.help(std.io.getStdOut().writer(), clap.Help, &params, .{});
return null;
} else if (res.args.usage != 0) {
try clap.usage(std.io.getStdOut().writer(), clap.Help, &params);
return null;
} else {
if (res.positionals.len < 1) {
std.log.err("Missing telnet URI. Use -h to print the help.\n", .{});
Expand Down

0 comments on commit e55f664

Please sign in to comment.