Skip to content
Discussion options

You must be logged in to vote

on this new day with restored vigor, i found something that does the trick

fn completer(current: &std::ffi::OsStr) -> Vec<CompletionCandidate> {
    let mut completions: Vec<CompletionCandidate> = Values::value_variants()
        .iter()
        .filter_map(Values::to_possible_value)
        .map(|x| CompletionCandidate::new(x.get_name()))
        .collect();

    completions.extend(PathCompleter::file().complete(current));

    completions
}

with add = ArgValueCompleter::new(completer)

full example
use std::path::PathBuf;

use clap::{
    Arg, Command, CommandFactory, Parser, ValueEnum,
    builder::{PossibleValue, TypedValueParser},
};
use clap_complete::{
    ArgValueCompleter, Compl…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@epage
Comment options

@epage
Comment options

Answer selected by quantenzitrone
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