pacak / bpaf

Command line parser with applicative interface
340 stars 17 forks source link

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

Closed ozwaldorf closed 6 days ago

ozwaldorf commented 1 month ago

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/
pacak commented 1 month ago

I think https://github.com/pacak/bpaf/pull/337 fixes it, started reviving it already. Hopefully soon.

ozwaldorf commented 1 month ago

I think https://github.com/pacak/bpaf/pull/337 fixes it, started reviving it already. Hopefully soon.

Awesome, looking forward to testing the changes

ozwaldorf commented 6 days ago

Seems like with all the changes on main, this issue is resolved!

image

pacak commented 6 days ago

Oh noes! I forgor to release!!!! :skull:

ozwaldorf commented 6 days ago

@pacak I was actually just about to ask! much appreciated :heart:

I should be able to cut a lutgen release after that