Skip to content

Commit

Permalink
Changed default Usage Format f/ Options
Browse files Browse the repository at this point in the history
- Removed the Value Name from Option Usage Messages by default.
  • Loading branch information
00JCIV00 committed Jul 15, 2024
1 parent 2f43111 commit 7ccfb9e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/covademo.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
7 changes: 3 additions & 4 deletions src/Option.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '-',
Expand Down Expand Up @@ -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(),
});
}
Expand Down
9 changes: 8 additions & 1 deletion src/utils.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit 7ccfb9e

Please sign in to comment.