From 7ccfb9e221dbb43ab005fc57705f1adcdfe31ef0 Mon Sep 17 00:00:00 2001 From: 00JCIV00 Date: Sun, 14 Jul 2024 22:27:03 -0400 Subject: [PATCH] Changed default Usage Format f/ Options - Removed the Value Name from Option Usage Messages by default. --- examples/covademo.zig | 2 +- src/Option.zig | 7 +++---- src/utils.zig | 9 ++++++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/examples/covademo.zig b/examples/covademo.zig index 565119c..30c233f 100644 --- a/examples/covademo.zig +++ b/examples/covademo.zig @@ -135,7 +135,7 @@ pub const CommandT = Command.Custom(.{ //}.help, //.global_case_sensitive = false, .opt_config = .{ - .usage_fmt = "{u}{?u}{s} {s}{?s} <{s} ({s})>", + //.usage_fmt = "{u}{?u}{s} {s}{?s} <{s} ({s})>", //.allow_arg_indices = false, //.global_case_sensitive = false, //.usage_fn = struct{ diff --git a/src/Option.zig b/src/Option.zig index e4d71a8..3bd3e31 100644 --- a/src/Option.zig +++ b/src/Option.zig @@ -91,11 +91,10 @@ pub const Config = struct { /// 3. String Name Separator /// 4. String (Long Prefix) /// 5. Optional String "{?s}" (Long Name) - /// 6. String (Value Name) - /// 7. String (Value Type) + /// 6. String (Value Type) /// /// Note, a comma "," will automatically be placed between the short and long name if they both exist. - usage_fmt: []const u8 = "{u}{?u}{s}{s}{?s} <{s} ({s})>", + usage_fmt: []const u8 = "{u}{?u}{s}{s}{?s} <{s}>", /// Prefix for Short Options. short_prefix: ?u8 = '-', @@ -329,7 +328,7 @@ pub fn Custom(comptime config: Config) type { if (self.short_name != null and self.long_name != null) name_sep_fmt else "", if (long_prefix != null and self.long_name != null) long_prefix.? else "", if (long_prefix != null) self.long_name orelse "" else "", - self.val.name(), + //self.val.name(), self.val.childType(), }); } diff --git a/src/utils.zig b/src/utils.zig index 8017977..6db559d 100644 --- a/src/utils.zig +++ b/src/utils.zig @@ -42,7 +42,14 @@ pub fn displayCmdInfo( /// Display what is captured within an Option or Value after Cova parsing. /// Meant for use within `displayCmdInfo()`. -fn displayValInfo(comptime ValueT: type, val: ValueT, name: ?[]const u8, isOpt: bool, alloc: mem.Allocator, writer: anytype) !void { +fn displayValInfo( + comptime ValueT: type, + val: ValueT, + name: ?[]const u8, + isOpt: bool, + alloc: mem.Allocator, + writer: anytype, +) !void { const prefix = if (isOpt) "Opt" else "Val"; switch (meta.activeTag(val.generic)) {