help: implement subcommand descriptions

I believe we've produced a superset of the functionality that was
present before rewriting all of the code.

There are still a lot of fiddly little details that need to be thought
through in order to produce something that is righteously flexible,
but I think this is in reasonable shape to start inventing real-world
uses for it.

Adding some tests, cleaning up a little bit of the allocation handling
(make better use of the arena allocators—we are definitely sort of
leaking memory at the moment), and writing documentation are still on
the roadmap.
This commit is contained in:
2023-04-02 17:15:37 -07:00
parent facda65271
commit 0d5dd9b36c
6 changed files with 258 additions and 109 deletions

View File

@@ -9,7 +9,7 @@ const cli = cmd: {
var cmd = CommandBuilder(u32).init(
\\The definitive noclip demonstration utility
\\
\\This command demonstrates the functionality of the noclip library. cool!!
\\This command demonstrates the functionality of the noclip library. cool!
);
cmd.add_option(.{ .OutputType = struct { u8, u8 } }, .{
.name = "test",
@@ -41,7 +41,6 @@ const cli = cmd: {
.name = "multi",
.short_tag = "-m",
.long_tag = "--multi",
.env_var = "NOCLIP_MULTI",
.description = "multiple specification test option",
});
cmd.add_flag(.{}, .{
@@ -54,11 +53,16 @@ const cli = cmd: {
cmd.add_flag(.{ .multi = true }, .{
.name = "multiflag",
.truthy = .{ .short_tag = "-M" },
.env_var = "NOCLIP_MULTIFLAG",
.description = "multiple specification test flag ",
});
cmd.add_option(.{ .OutputType = u8 }, .{
.name = "env",
.env_var = "NOCLIP_ENVIRON",
.description = "environment variable only option",
});
cmd.add_argument(.{ .OutputType = []const u8 }, .{
.name = "arg",
.description = "This is an argument that doesn't really do anything, but it's very important.",
});
break :cmd cmd;