clap-rs / clap

A full featured, fast Command Line Argument Parser for Rust
docs.rs/clap
Apache License 2.0
14.26k stars 1.04k forks source link

Nushell completions should use `glob` type for paths #5605

Open KAAtheWiseGit opened 3 months ago

KAAtheWiseGit commented 3 months ago

Please complete the following tasks

Rust Version

rustc 1.80.0 (051478957 2024-07-21) (Alpine Linux 1.80.0-r0)

Clap Version

4.4.6 (4.5.3 for clap_complete_nushell)

Minimal reproducible code

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

use std::path::PathBuf;

#[derive(Parser)]
pub struct Options {
    path: PathBuf,

    rest: Vec<PathBuf>,
}

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

Steps to reproduce the bug with the above code

cargo run

Actual Behaviour

The following completion is generated:

module completions {

  export extern sd [
    path: string
    ...rest: string
    --help(-h)                # Print help
  ]

}

export use completions *

Expected Behaviour

Additional Context

No response

Debug Output

[clap_builder::builder::command]Command::_build: name="compl"
[clap_builder::builder::command]Command::_propagate:compl
[clap_builder::builder::command]Command::_check_help_and_version:compl expand_help_tree=true
[clap_builder::builder::command]Command::long_help_exists
[clap_builder::builder::command]Command::_check_help_and_version: Building default --help
[clap_builder::builder::command]Command::_propagate_global_args:compl
[clap_builder::builder::debug_asserts]Command::_debug_asserts
[clap_builder::builder::debug_asserts]Arg::_debug_asserts:path
[clap_builder::builder::debug_asserts]Arg::_debug_asserts:rest
[clap_builder::builder::debug_asserts]Arg::_debug_asserts:help
[clap_builder::builder::debug_asserts]Command::_verify_positionals
[clap_builder::builder::command]Command::_build_bin_names
[ clap_builder::output::usage]Usage::get_required_usage_from: incls=[], matcher=false, incl_last=true
[ clap_builder::output::usage]Usage::get_required_usage_from: unrolled_reqs=["path"]
[ clap_builder::output::usage]Usage::get_required_usage_from:iter:"path" arg is_present=false
[ clap_builder::output::usage]Usage::get_required_usage_from: ret_val=[StyledStr("<PATH>")]
epage commented 3 months ago

clap_complete_nushell does not yet have support for ValueHint. Someone is welcome to contribute it and/or add Rust-native nushell completion support (see also #3166).

Note: we implicitly set the ValueHint based on an Arg being a PathBuf, see https://github.com/clap-rs/clap/blob/16fba4b9f91cf772ab1f6e7b1016a257e5f6cf62/clap_builder/src/builder/arg.rs#L4023-L4037