Releases: Hejsil/zig-clap
Releases · Hejsil/zig-clap
zig-clap-0.2.0
A new release of zig-clap
for zig 0.6.0
Changes
Breaking
- Now compilers with the
zig 0.6.0
compiler. - Removes the
clap.args.Iterator
struct in favor of passing the argument iterator type directly to the different parsers.- These diffs show the difference between the two API's
-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 thearg[0]
oninit
and has a field calledexe
where this argument is stored.- This puts this iterator more in line with how all the others are used.
- These diffs show the difference between the two API's
clap.help
and friends now takeParam(Help)
instead ofParam([]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.
New
- Adds
clap.parseParam
which takes a string similar to whatclap.help
emits for each parameter and returns aParam(Help)
- Most users will find this API more convenient than initializing all the fields of
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, }, );
- Most users will find this API more convenient than initializing all the fields of
- Adds
clap.parse
. This is the new simplest way of usingzig-clap
. - Adds
clap.usage
. This function takes a slice ofParam(Help)
and a stream and prints a usage string based on the parameters passed.- Just like
help
this function has anEx
andFull
version.
- Just like
zig-clap-0.1.0
The first release of zig-clap
.
Added
clap.args.Iterator
.- The common interface for iterating over program arguments.
- Used by the rest of the library.
clap.args.SliceIterator
- An
clap.args.Iterator
which just iterates over a slice of strings.
- An
clap.args.OsIterator
- An
clap.args.Iterator
which wrapsstd.os.ArgIterator
- It iterates over the program arguments the most memory efficient way on each platform.
- An
clap.StreamingClap
- A streaming argument parser. which, given a slice of parameters can parse arguments lazily.
- This parse is used as a backend for other parsers.
clap.ComptimeClap
- A parse which uses reflection to generate an efficient way of querying what parameters have been passed, and their values.
clap.help
,clap.helpEx
andclap.helpFull
- Functions for pretty printing parameters.