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

Support arg_require_else_help natively in the derive #5291

Open
epage opened this issue Jan 8, 2024 · 1 comment
Open

Support arg_require_else_help natively in the derive #5291

epage opened this issue Jan 8, 2024 · 1 comment
Labels
A-derive Area: #[derive]` macro API C-enhancement Category: Raise on the bar on expectations S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing

Comments

@epage
Copy link
Member

epage commented Jan 8, 2024

Right now, users of arg_required_else_help must define their args as being overrideable by the subcommand, even if generally required:

#[derive(Parser)]
struct Cli {
    #[arg(long, required = true)]
    input: Option<PathBuf>,
    #[command(subcommand)]
    subcommand: Option<Subcommand>,
}

In the derive, we could instead express this as

#[derive(Parser)]
enum Cli {
    #[command(these_are_top_level_args)]
    Args {
        #[arg(long)]
        input: PathBuf,
    },
    // ...
}

The main question is what to call these_are_top_level_args attribute.

@epage epage added A-derive Area: #[derive]` macro API S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing labels Jan 8, 2024
@epage
Copy link
Member Author

epage commented Jan 8, 2024

Could we just use flatten and rely on it being a variant-struct to distinguish it from other flatten?

Probably not because someone might want to define those args in a different struct and then the syntax would be ambiguous and we wouldn't know what code to generate.

@epage epage added the C-enhancement Category: Raise on the bar on expectations label Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-derive Area: #[derive]` macro API C-enhancement Category: Raise on the bar on expectations S-waiting-on-design Status: Waiting on user-facing design to be resolved before implementing
Projects
None yet
Development

No branches or pull requests

1 participant