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

Ability to forward completions in Rust native completions #5653

Open
epage opened this issue Aug 10, 2024 · 2 comments
Open

Ability to forward completions in Rust native completions #5653

epage opened this issue Aug 10, 2024 · 2 comments
Labels
A-completion Area: completion generator C-enhancement Category: Raise on the bar on expectations E-hard Call for participation: Experience needed to fix: Hard / a lot

Comments

@epage
Copy link
Member

epage commented Aug 10, 2024

  • cargo run
  • cargo <plugin>

and likely other cases require completing other commands.

See https://carapace-sh.github.io/carapace-bin/spec/embed.html

@epage epage added E-medium Call for participation: Experience needed to fix: Medium / intermediate A-completion Area: completion generator C-enhancement Category: Raise on the bar on expectations labels Aug 10, 2024
@shannmu
Copy link
Contributor

shannmu commented Aug 29, 2024

This feature is undoubtedly a powerful capability. Let me try to explain my understanding of this feature.

For external subcommand completions, we can categorize them into cases that require forward completions and those that do not.

  • For cases that do not require forward completions, such as cargo <alias>, this is simple to implement.

  • For cases that require forward completions, such as mycommand git [TAB], we need to address the following:

    For external subcommand completions, we might need to clarify the type of subcommand. I categorize them into external commands implemented by clap and those not implemented by clap:

    • For external commands implemented by clap: We could potentially save some metadata in a special path, which might allow us to achieve shell-independent completions within clap itself. We might call COMPLETE=<shell> external_subcommand -- xx xx xx xx to obtain completion results.

    • For external commands not implemented by clap: Their completions are necessarily shell-specific because we have no knowledge about how to complete them or what their completion scripts are like. We need to construct a new command-line input (excluding argv[0]) and then invoke some shell built-in commands (or write a script) to obtain completion results.

      • fish
        complete --do-complete="<command line>" could get the completion of <command line>

      • bash
        We could reset COMP_LINE, COMP_WORDS, COMP_POINT, COMP_CWORD to get completions from COMPRELAY

      • There are also some other shells for which I am currently unsure how to implement this feature.

@epage epage added E-hard Call for participation: Experience needed to fix: Hard / a lot and removed E-medium Call for participation: Experience needed to fix: Medium / intermediate labels Aug 29, 2024
@epage
Copy link
Member Author

epage commented Aug 29, 2024

For cases that do not require forward completions, such as cargo , this is simple to implement.

I view this as separate from this issue though it would be good to have a way to solve it.

For external commands implemented by clap:

imo users and other applications should not be aware an application is using clap.

For external commands not implemented by clap:

This is likely what we'll need to do.

I put this as one of the lowest priority items. I do not believe it is needed for parity with existing clap_complete or for cargo.

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 E-hard Call for participation: Experience needed to fix: Hard / a lot
Projects
None yet
Development

No branches or pull requests

2 participants