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

Support Base Path for ValueHint::*Path types #5427

Closed
2 tasks done
Swivelgames opened this issue Mar 26, 2024 · 1 comment
Closed
2 tasks done

Support Base Path for ValueHint::*Path types #5427

Swivelgames opened this issue Mar 26, 2024 · 1 comment
Labels
A-completion Area: completion generator C-enhancement Category: Raise on the bar on expectations

Comments

@Swivelgames
Copy link

Swivelgames commented Mar 26, 2024

Please complete the following tasks

Clap Version

4.4.7

Describe your use case

There are certain parameters that I would like to complete using paths. However, some of that paths aren't relative to the Current Working Directory.

Describe the solution you'd like

It would be great if you could specify a base directory for Path-like completions. In a Utopian world, it would also be great to include an optional max-depth:

pub enum ValueHint {
    // ...
    AnyChildPath(PathBuf, Int),
    FileChildPath(PathBuf, Int),
    DirChildPath(PathBuf, Int),
    ExecutableChildPath(PathBuf, Int),
    // ...
}
let start_path = PathBuf::from("/some/path");
let depth = 1;
let hint = Vault::Hint(start_path, depth);

Alternatives, if applicable

The alternative that I'm exploring right now is rolling my own completion for Path, which isn't ideal.

@Swivelgames Swivelgames added the C-enhancement Category: Raise on the bar on expectations label Mar 26, 2024
@epage epage added the A-completion Area: completion generator label Mar 26, 2024
@epage
Copy link
Member

epage commented Mar 26, 2024

Note that ValueHint is specifically meant to capture native shell completions.

#1232 is our issue for allowing the user to provide custom completers which is blocked on #3166.

I'm going to close in favor of #1232 as we likely won't support every case for users. We can observe users and maybe pull some things in that are frequently used but I don't want to speculatively keep this issue as open in case this ends up being one of the cases. After the community has adopted #1232, if there is enough of a case that this pattern is common, we can re-evaluate then.

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Mar 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completion Area: completion generator C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

No branches or pull requests

2 participants