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

[nushell] Generates invalid completions when variadic arg is used with last=true arg #5771

Open
2 tasks done
milesj opened this issue Oct 9, 2024 · 1 comment
Open
2 tasks done
Labels
A-completion Area: completion generator C-bug Category: Updating dependencies E-medium Call for participation: Experience needed to fix: Medium / intermediate

Comments

@milesj
Copy link

milesj commented Oct 9, 2024

Please complete the following tasks

Rust Version

rustc 1.81.0 (eeb90cda1 2024-09-04)

Clap Version

4.5.19

Minimal reproducible code

use clap::Args;
use clap_complete::generate;
use clap_complete_nushell::Nushell;

#[derive(Args)]
pub struct ExampleArgs {
    #[arg(required = true, help = "...")]
    pub id: Vec<String>,

    // after --
    #[arg(last = true, help = "...")]
    pub passthrough: Vec<String>,
}

#[derive(Subcommand)]
pub enum CliCommand {
  #[command(name = "example")
  Example(ExampleArgs),
}

#[derive(Parser)]
pub struct Cli {
  #[command(subcommand)]
  pub command: CliCommand,
}

fn main() {
  let mut app = Cli::command();
  let mut stdio = std::io::stdout();
  generate(Nushell, &mut app, "bin", &mut stdio);
}

Steps to reproduce the bug with the above code

cargo run -- example

Actual Behaviour

It generates a completion that uses ...<arg>: string syntax for both the variadic arg, and the last arg. This results in Nu erroring with "Multiple rest params".

Example: https://cdn.discordapp.com/attachments/974160221452763149/1289506849053343845/image.png?ex=6706ea16&is=67059896&hm=6df6cb538be11ccf5a531f46c2dab73013e965749fe809a95287666b16188803&

Expected Behaviour

This generates a valid completion. We probably want to omit last args entirely.

Additional Context

No response

Debug Output

No response

@milesj milesj added the C-bug Category: Updating dependencies label Oct 9, 2024
@epage epage added E-medium Call for participation: Experience needed to fix: Medium / intermediate A-completion Area: completion generator labels Oct 9, 2024
@epage
Copy link
Member

epage commented Oct 9, 2024

If we have to choose between one, seems fine to drop last.

Note that completions are mostly driven by users so if you want this fixed, doing it yourself is the most likely way for that to happen.

What would help even more is if someone implemented nushell support for #3166 so we'd no longer be limited by what nushell's completion rules support and if something gets implemented for one shell, most likely all shells benefit.

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-bug Category: Updating dependencies E-medium Call for participation: Experience needed to fix: Medium / intermediate
Projects
None yet
Development

No branches or pull requests

2 participants