Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ozwaldorf opened this issue Jul 23, 2024 · 5 comments

Comments

@ozwaldorf
Copy link
Contributor

ozwaldorf commented Jul 23, 2024

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
Copy link
Owner

pacak commented Jul 23, 2024

I think #337 fixes it, started reviving it already. Hopefully soon.

@ozwaldorf
Copy link
Contributor Author

I think #337 fixes it, started reviving it already. Hopefully soon.

Awesome, looking forward to testing the changes

@ozwaldorf
Copy link
Contributor Author

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

image

@pacak
Copy link
Owner

pacak commented Sep 6, 2024

Oh noes! I forgor to release!!!! 💀

@ozwaldorf
Copy link
Contributor Author

@pacak I was actually just about to ask! much appreciated ❤️

I should be able to cut a lutgen release after that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants