Skip to content

[feat][plugin-cli] support parsing unconfigured argmuents #2694

Open
@J-ZhengLi

Description

@J-ZhengLi

In clap, there are two options for positional args which I found quite useful, they are allow_hyphen_values and trailing_var_arg. Which make it easy to parse arguments that are not per-configured.

Why

Let's say I'm writing a GUI wrapper to another program that has many CLI options, and I want the user to start my program with the same options of that other program (i.e. cargo).

So if the user run my-program build --vcs none --lib --edition 2024 -v hello_world, I want the parser to collect all arguments after build without me redefine all those same options.

In clap, I can use something like this:

enum Subcommands {
    Build {
        #[arg(
            trailing_var_arg = true,
            allow_hyphen_values = true,
            value_name = "ARGS"
        )]
        extra_args: Vec<String>,
    }
}

But I don't know if its possible to do the same thing using the cli plugin

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions