Hejsil / Hejsil/zig-clap

Support for more complex parameters

Open
#35 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Zig
Stars
1.6k
Forks
99
Avg merge
3h 53m
Merged PRs (30d)
1

Description

I'd like to parse something like `--mode x[@Hz]`.
To my from my current understanding this is not possible.

I intended to write it as follows:
```zig
const params = comptime [_]clap.Param(clap.Help) {
.{
.id = .{.msg = "defines the output mode", .value = "x[@Hz]"},
.names = .{ .short = 'm', .long = "mode" },
.takes_value = .One,
},
};

var args = try clap.parse(clap.Help, ¶ms, std.heap.page_allocator, null);
defer args.deinit();

if (args.option("--mode")) |n| {
// Parse width,height and refresh manually
}

```

This would work but is to some extend a hack. The main problem with this is that all `help*` functions become useless because they put `<>` around the value string.

A simple fix would be to make the formatting in `parseParam` accept a custom formatstring. But I am not sure that this is the right solution.

When this usecase is considered valid then I'll spend some time thinking about a good solution.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.