Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp UsageHelpConfig to DefaultArgsConfig #62

Open
00JCIV00 opened this issue Sep 20, 2024 · 0 comments
Open

Revamp UsageHelpConfig to DefaultArgsConfig #62

00JCIV00 opened this issue Sep 20, 2024 · 0 comments
Labels
enhancement New feature or request
Milestone

Comments

@00JCIV00
Copy link
Owner

00JCIV00 commented Sep 20, 2024

Currently, the UsageHelpConfig works under the assumption that library users will always want to either use both Usage and Help or neither, but not one or the other. It's also only limited to those two Arguments.

This new API would solve both of these issues:

  1. Allow library users to choose exactly which Default Arguments they'd like to implement.
  2. Create an API that's flexible to additional Default Arguments in the future w/o causing breaking changes. (For example, adding Version alongside Usage and Help).

DefaultArgsConfig Example:

        /// Config for auto-generating Default Commands & Options during Initialization.
        pub const DefaultArgsConfig = struct{
            /// Add selected Default Commands to this Command and its sub-Commands.
            add_def_cmds: ?[]const DefaultArgKinds = &.{ .usage, .help, .version },
            /// Add selected Default Options to this Command and its sub-Commands.
            add_def_opts: ?[]const DefaultArgKinds = &.{ .usage, .help, .version },
            /// Set a name format for the Usage Options inner Value.
            /// This only takes effect if `add_def_opts` is not null or empty.
            /// Must support the following format types in this order:
            /// 1. String (Default Option Name)
            def_val_name: []const u8 = "{s}_flag",
            /// Set a description format for the Usage Command & Option.
            /// Must support the following format types in this order:
            /// 1. String (Command Name)
            /// 2. String (Default Command Name)
            def_desc_fmt: []const u8 = "Show the '{s}' {s} display.",
            /// Add a Command Group for Default Commands.
            /// Note, this will only take effect if `add_def_cmds` is not null or empty.
            add_def_cmd_group: AddDefaultGroup = .AddIfOthers,
            /// Add an Option Group for Default Options.
            /// Note, this will only take effect if `add_def_opts` is not null or empty.
            add_def_opt_group: AddHelpGroup = .AddIfOthers,
            /// Default Argument Group Name.
            def_arg_group_name: []const u8 = "INFO",

            /// Determine behavior for adding a Default Argument Group.
            pub const AddDefaultGroup = enum{
                /// Add if there are other Argument Groups.
                AddIfOthers,
                /// Add regardless of other Argument Groups.
                Add,
                /// Do not add.
                DoNotAdd,
            };
            
            /// Default Argument Kinds
            pub const DefaultArgKinds = enum {
                usage,
                help,
                version,
            };
        };
@00JCIV00 00JCIV00 added the enhancement New feature or request label Sep 20, 2024
@00JCIV00 00JCIV00 added this to the v0.11.0-beta milestone Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant