Skip to content

How to have an multi-valued option with auto generated help? #197

Answered by pacak
VorpalBlade asked this question in Q&A
Discussion options

You must be logged in to vote

It should be possible to implement as combinatoric function similar to here.

You define a parser for template field something like this:

fn template() -> impl Parser<Style> {
    let help_msg = format!("....."); // <- you can use `strum` to get exact names and put it in the help message in a way you like

    // again, with help of strum you can get a list of values and decide if it maches
    fn complete_fn(input: &String) -> Vec<...> {}

    // name
    short('t').long("template")
        .help(help_msg) // help mesage generated by strum
        .argument::<String>("ARG")  // consume it as string because completion will need a string to work with
        .complete(complete_fn) // try to…

Replies: 2 comments 9 replies

Comment options

You must be logged in to vote
9 replies
@pacak
Comment options

@VorpalBlade
Comment options

@pacak
Comment options

@VorpalBlade
Comment options

@pacak
Comment options

Answer selected by VorpalBlade
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants