Skip to content

File completions from a positional always show while completing a flag with a custom impl #377

Description

@ozwaldorf

With a flag parser like so:
https://github.com/ozwaldorf/lutgen-rs/blob/b510e80f0c48d8807a20812b6fc2a9971297d8e4/src/bin.rs#L83-L96

    pub fn flag_parser() -> impl Parser<Self> {
        long("palette")
            .short('p')
            .argument::<String>("PALETTE")
            .help(Self::HELP)
            .complete(|v| {
                DynamicPalette::suggestions(v)
                    .into_iter()
                    .map(|(_, name)| (name, None))
                    .collect()
            })
            .parse(|s| DynamicPalette::from_str(&s))
    }

And a positional parser that uses complete shell:
https://github.com/ozwaldorf/lutgen-rs/blob/b510e80f0c48d8807a20812b6fc2a9971297d8e4/src/bin.rs#L537-L545

        /// Images to correct, using the generated or provided hald clut.
        #[bpaf(
            positional("IMAGES"),
            non_strict,
            guard(|v| v.exists(), "No such file or directory"),
            complete_shell(ShellComp::File { mask: Some(IMAGE_GLOB) }),
            some("At least one image is needed to apply"),
        )]
        input: Vec<PathBuf>,

Completions for the input positional always show, even when flag (palette) completions should only be shown:

● lutgen apply docs/example-image.jpg -p <TAB>  
                                 PALETTE                       <--- palette completions
directory                                                      <--- file completions
benches/   docs/      palettes/  result@    src/       target/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions