Bot releases are visible (Hide)
zig-clap
release 0.9.1
which compiles and works for zig 0.13.0
and zig 0.12.0
zig-clap
to be compiled with both 0.12
and 0.13
versions of Zig #128Published by Hejsil 4 months ago
zig-clap
release 0.9.0
which compiles and works for zig 0.13.0
Published by Hejsil 6 months ago
zig-clap
release 0.8.0
which compiles and works for zig 0.12.0
gyro
and zigmod
clap.ParseOptions
Published by Hejsil about 1 year ago
zig-clap
release 0.7.0
which compiles and works for zig 0.11.0
u8
instead of bool
.zig-clap
will look something like this:- if (arg_result.my_flag)
+ if (arg_result.my_flag != 0)
zig-clap
now exposes itself as a module in the build script.Published by Hejsil almost 2 years ago
zig-clap
release 0.6.0
which compiles and works for zig 0.10.0
zig-clap
is now under the MIT license instead of Unlicense #64
Refactor the clap.ArgIterator
interface to be the same interface as std.process.ArgIterator
clap.StreamingClap
has been moved to clap.streaming.Clap
clap.parseParam
can now parse a parameter spanning multiple lines and is overall more robust than before.
clap.parse
and clap.parseEx
has had their return type changed. Instead of returning a struct with .flag
, .option
, .options
and .positionals
methods, it now just returns a struct with fields for each parameter your program takes.
clap.parse
and clap.parseEx
takes an additional argument, which use used to lookup the parser that should be used for each parameter.zig-clap
will look something like this:- var args = clap.parse(clap.Help, ¶ms, .{
+ var args = clap.parse(clap.Help, ¶ms, clap.parsers.default, .{
- if (args.flag("--help"))
+ if (args.args.help)
debug.print("--help\n", .{});
- if (args.option("--number")) |n|
- debug.print("--number = {s}\n", .{n});
- for (args.options("--string")) |s|
+ if (args.args.number) |n|
+ debug.print("--number = {}\n", .{n});
+ for (args.args.string) |s|
debug.print("--string = {s}\n", .{s});
- for (args.positionals()) |pos|
+ for (args.positionals) |pos|
debug.print("{s}\n", .{pos});
}
clap.help
and clap.usage
are now generic and expect the Id
in Param(Id)
to provide getters for description
and value
. Usage of clap.help
and clap.usage
require the following change:
- try help(stream, params);
+ try help(stream, clap.Help, params);
- try usage(stream, params);
+ try usage(stream, clap.Help, params);
clap.help
now also takes an option parameter that configures how the parameters should be formatted. You can leave it empty for a good default:
- try help(stream, clap.Help, params);
+ try help(stream, clap.Help, params, .{});
clap.parseParamEx
which is the same as clap.parseParam
, but takes a pointer to end
and sets that to the latest byte parsed before returning either an error or a value.clap.parseParams
and clap.parseParamsEx
which parse a string into a slice of multiple parameters.clap.parseParamsIntoSlice
and clap.parseParamsIntoSliceEx
which parse a string into multiple parameters, which are stored into a slice passed in by the caller.clap.parseParamsIntoArrayList
and clap.parseParamsIntoArrayListEx
which parse a string into multiple parameters, which are stored into an ArrayList
passed in by the caller.clap.parseParamsComptime
which parse a string into a slice of multiple parameters at compile time, returning a fixes size array.
zig-clap
. The following change is recommended, but not necessary.- const params = comptime [_]clap.Param(clap.Help){
- clap.parseParam("-h, --help Display this help and exit.") catch unreachable,
- clap.parseParam("-n, --number <usize> An option parameter, which takes a value.") catch unreachable,
- clap.parseParam("-s, --string <str>... An option parameter which can be specified multiple times.") catch unreachable,
- clap.parseParam("<str>...") catch unreachable,
- };
+ const params = comptime clap.parseParamsComptime(
+ \\-h, --help
+ \\ Display this help and exit.
+ \\-n, --number <usize>
+ \\ An option parameter, which takes a value.
+ \\-s, --string <str>...
+ \\ An option parameter which can be specified multiple times.
+ \\<str>...
+ \\
+ );
clap.args.OsIterator
. Use std.process.ArgIterator
insteadargs.ShellIterator
. Use std.process.ArgIteratorGeneral
insteadclap.ComptimeClap
. Use clap.parse
and clap.parseEx
insteadclap.helpEx
, clap.helpFull
. Implement the description
and value
methods on your Id
and use clap.help
insteadclap.usageEx
, clap.usageFull
. Implement the description
and value
methods on your Id
and use clap.help
insteadclap.usage
now prints many value positional parameters correctly as <file>...
instead of <file>
Published by Hejsil almost 3 years ago
zig-clap
release 0.5.0
which compiles and works for zig 0.9.0
clap.help
now indents each newline in the help string.clap.parse
did not forward diagnostics down to the underlying StreamingClap
.Published by Hejsil over 3 years ago
Discovered by @omgitsmoe, 0.4.0
had a critical bug in clap.parse
.
clap.parseParam
to a high value to avoid having users needing to specify it themselves (#42)Published by Hejsil over 3 years ago
zig-clap
release 0.4.0
which compiles and works for zig 0.8.0
.
--
will now all be treated like positional arguments, even if they match something else.
-a -b
gives you the flags a
and b
-a -- -b
gives you the flag a
and the positional argument -b
.clap.StreamingClap
and clap.parse
.clap.parse
and clap.parseEx
now takes a ParserOptions
allocator
and diag
arguments from these functions and moves them into this new struct.clap.StreamingClap.next
no longer takes the diag
argument.
diagnostic
field have been added to this parser.snake_case
.args.ShellIterator
(this might actually have been in 0.3.0
but it wasn't in the release notes 🤷)
sh
or bash
would.zig-clap
through both gyro
and zigmod
package managers.
zig-clap
can also be found on the astrolab
package repository.Published by Hejsil almost 4 years ago
A new release of zig-clap
for zig 0.7.0
zig 0.7.0
compiler.clap.parse
now supports capturing multiple options.
take_values
field be clap.Values.Many
.
clap.parseParam
has syntax for this: clap.parseParam("-s, --ss <V>... This is a help message")
.options
function can be called to get a slice of all options passed the parameter.clap.Diagnostic
struct has a report
method which prints a simple English error message.
null
can be pass if the caller does not care about this extra information.clap.parseParam
now supports parsing positional parameter help messages.
clap.parseParam("<P> This is a positional parameter")
.clap.args.OsIterator
now returns null-terminated strings.Published by Hejsil over 4 years ago
A new release of zig-clap
for zig 0.6.0
zig 0.6.0
compiler.clap.args.Iterator
struct in favor of passing the argument iterator type directly to the different parsers.
-var os_iter = clap.args.OsIterator.init(allocator);
-const iter = &os_iter.iter;
-defer os_iter.deinit();
+var iter = clap.args.OsIterator.init(allocator);
+defer iter.deinit();
-var args = try clap.ComptimeClap([]const u8, params).parse(allocator, clap.args.OsIterator.Error, iter);
+var args = try clap.ComptimeClap([]const u8, params).parse(allocator, clap.args.OsIterator, &iter);
clap.args.OsIterator
now also consumes the arg[0]
on init
and has a field called exe
where this argument is stored.
clap.help
and friends now take Param(Help)
instead of Param([]const u8)
clap.help
output is now slightly different:
+ -d, --dd <V3> Both option.
- -d, --dd=V3 Both option.
-
and --
strings will now be interpreted as positional and not as arguments.clap.parseParam
which takes a string similar to what clap.help
emits for each parameter and returns a Param(Help)
Param
themself:
try clap.help(
stderr,
- [_]clap.Param([]const u8){
- clap.Param([]const u8){
- .id = "Display this help and exit.",
- .names = clap.Names{ .short = 'h', .long = "help" },
- },
- clap.Param([]const u8){
- .id = "Output version information and exit.",
- .names = clap.Names{ .short = 'v', .long = "version" },
- },
+ comptime [_]clap.Param(clap.Help){
+ clap.parseParam("-h, --help Display this help and exit. ") catch unreachable,
+ clap.parseParam("-v, --version Output version information and exit.") catch unreachable,
},
);
clap.parse
. This is the new simplest way of using zig-clap
.clap.usage
. This function takes a slice of Param(Help)
and a stream and prints a usage string based on the parameters passed.
help
this function has an Ex
and Full
version.Published by Hejsil almost 6 years ago
The first release of zig-clap
.
clap.args.Iterator
.
clap.args.SliceIterator
clap.args.Iterator
which just iterates over a slice of strings.clap.args.OsIterator
clap.args.Iterator
which wraps std.os.ArgIterator
clap.StreamingClap
clap.ComptimeClap
clap.help
, clap.helpEx
and clap.helpFull