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

Disable generating arguments after double hyphen for nushell #5592

Open
2 tasks done
ndtoan96 opened this issue Jul 21, 2024 · 1 comment
Open
2 tasks done

Disable generating arguments after double hyphen for nushell #5592

ndtoan96 opened this issue Jul 21, 2024 · 1 comment
Labels
A-completion Area: completion generator C-bug Category: Updating dependencies E-medium Call for participation: Experience needed to fix: Medium / intermediate

Comments

@ndtoan96
Copy link

Please complete the following tasks

Rust Version

rustc 1.78.0 (9b00956e5 2024-04-29)

Clap Version

4.3.5

Minimal reproducible code

use std::{ffi::OsString, io, path::PathBuf};

use clap::{CommandFactory, Parser};
use clap_complete::generate;
use clap_complete_nushell::Nushell;

#[derive(Parser, Debug)]
pub struct RuffArgs {
    /// List of files or directories to limit the operation to
    paths: Vec<PathBuf>,
    /// Perform the operation on all packages
    #[arg(short, long)]
    all: bool,
    /// Perform the operation on a specific package
    #[arg(short, long)]
    package: Vec<String>,
    /// Use this pyproject.toml file
    #[arg(long, value_name = "PYPROJECT_TOML")]
    pyproject: Option<PathBuf>,
    /// Enables verbose diagnostics.
    #[arg(short, long)]
    verbose: bool,
    /// Turns off all output.
    #[arg(short, long, conflicts_with = "verbose")]
    quiet: bool,
    /// Extra arguments to ruff
    #[arg(last = true)]
    extra_args: Vec<OsString>,
    
}

fn main() {
    let mut cmd = RuffArgs::command();
    generate(Nushell,  &mut cmd,"myapp", &mut io::stdout());
}

Steps to reproduce the bug with the above code

  1. cargo run
  2. copy the code to nushell env.nu
  3. reload nushell
  4. see error

Actual Behaviour

Error: nu::parser::multiple_rest_params

  × Multiple rest params.
    ╭─[D:\dev_env\conf\nushell\scripts\rye.nu:85:28]
 84 │       # Run the code formatter on the project
 85 │ ╭─▶   export extern "rye fmt" [
 86 │ │       ...paths: string          # List of files or directories to limit the operation to
 87 │ │       --all(-a)                 # Perform the operation on all packages
 88 │ │       --package(-p): string     # Perform the operation on a specific package
 89 │ │       --pyproject: string       # Use this pyproject.toml file
 90 │ │       --verbose(-v)             # Enables verbose diagnostics
 91 │ │       --quiet(-q)               # Turns off all output
 92 │ │       ...extra_args: string     # Extra arguments to ruff
 93 │ │       --check                   # Run format in check mode
 94 │ │       --help(-h)                # Print help (see more with '--help')
 95 │ ├─▶   ]
    · ╰──── multiple rest params
 96 │
    ╰────

Expected Behaviour

Completion should not cause error in nushell.

Additional Context

No response

Debug Output

No response

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

epage commented Jul 22, 2024

Ideally in fixing this, someone would write integration tests with completest-nu

Please add the tests in the first commit with them passing, showing the current bug. The following commit would fix the behavior and update the test so it still passes.

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