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

Implement common flags and options #32

Closed
rsore opened this issue Oct 14, 2024 · 0 comments · Fixed by #40
Closed

Implement common flags and options #32

rsore opened this issue Oct 14, 2024 · 0 comments · Fixed by #40
Labels
feature New feature good first issue Good for newcomers

Comments

@rsore
Copy link
Owner

rsore commented Oct 14, 2024

A detail that increases verbosity of the library API is defining custom flags and options. There are a lot of common flags and options that programs use, such as --verbose and --config. The library should provide many of these so the users don't need to make custom types for them. Here is a proposed implementation:

namespace CLArgs::CommonFlags
{
    template <::CLArgs::StringLiteral Description = "Enable verbose output">
    using Verbose = ::CLArgs::Flags<"--verbose,-v", Description>;
}

namespace CLArgs::CommonOptions
{
    template <::CLArgs::StringLiteral Description = "Specify configuration file">
    using ConfigurationFile= ::CLArgs::Option<"--configuration,--config,-c", "<filepath>", Description, std::filesystem::path>;
}

Instead of defining their own custom types for these common flags and options, they can simply use these predefined types, optionally providing a custom description more relevant to their specific program:

using Parser = CLArgs::Parser<CLArgs::CommonFlags::Verbose,
                              CLArgs::CommonOptions::Configuration<"My custom description">>;

This would be a very simple improvement to the library, but a very valuable addition.

@rsore rsore added feature New feature good first issue Good for newcomers labels Oct 14, 2024
@rsore rsore closed this as completed in #40 Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant