Repository: clap-rs/clap (language: rust)

Issue:
Nushell completions should use `glob` type for paths
### Please complete the following tasks

- [X] I have searched the [discussions](https://github.com/clap-rs/clap/discussions)
- [x] I have searched the [open](https://github.com/clap-rs/clap/issues) and [rejected](https://github.com/clap-rs/clap/issues?q=is%3Aissue+label%3AS-wont-fix+is%3Aclosed) issues

### 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

```rust
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:

```Nushell
module completions {

  export extern sd [
    path: string
    ...rest: string
    --help(-h)                # Print help
  ]

}

export use completions *
```

### Expected Behaviour

- Arguments with type `PathBuf` should have the `path` type in the completions, so that the native path completion works.
- Arguments with type `Vec<PathBuf>` should have the `glob` type, otherwise globbing breaks: `sd a *` will return an error, because path `*` doesn't exist. 

### 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>")]
```


Discussion / hints:
`clap_complete_nushell` does not yet have support for [ValueHint](https://docs.rs/clap/latest/clap/enum.ValueHint.html).  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

Fix patch:
diff --git a/clap_complete_nushell/src/lib.rs b/clap_complete_nushell/src/lib.rs
index e7f064e2d4a..b95a835e526 100644
--- a/clap_complete_nushell/src/lib.rs
+++ b/clap_complete_nushell/src/lib.rs
@@ -23,6 +23,7 @@
 #![warn(clippy::print_stdout)]
 
 use clap::builder::StyledStr;
+use clap::ValueHint;
 use clap::{builder::PossibleValue, Arg, ArgAction, Command};
 use clap_complete::Generator;
 
@@ -65,7 +66,23 @@ fn append_value_completion_and_help(
         .unwrap_or(false);
 
     if takes_values {
-        s.push_str(": string");
+        let nu_type = match arg.get_value_hint() {
+            ValueHint::Unknown => "string",
+            ValueHint::Other => "string",
+            ValueHint::AnyPath => "path",
+            ValueHint::FilePath => "path",
+            ValueHint::DirPath => "path",
+            ValueHint::ExecutablePath => "path",
+            ValueHint::CommandName => "string",
+            ValueHint::CommandString => "string",
+            ValueHint::CommandWithArguments => "string",
+            ValueHint::Username => "string",
+            ValueHint::Hostname => "string",
+            ValueHint::Url => "string",
+            ValueHint::EmailAddress => "string",
+            _ => "string",
+        };
+        s.push_str(format!(": {nu_type}").as_str());
 
         if !possible_values.is_empty() {
             s.push_str(format!(r#"@"nu-complete {} {}""#, name, arg.get_id()).as_str());


Test patch:
diff --git a/clap_complete_nushell/tests/snapshots/feature_sample.nu b/clap_complete_nushell/tests/snapshots/feature_sample.nu
index 78e772bc7ea..eb081b9b4de 100644
--- a/clap_complete_nushell/tests/snapshots/feature_sample.nu
+++ b/clap_complete_nushell/tests/snapshots/feature_sample.nu
@@ -6,7 +6,7 @@ module completions {
 
   # Tests completions
   export extern my-app [
-    file?: string             # some input file
+    file?: path               # some input file
     --config(-c)              # some config file with another line
     --conf                    # some config file with another line
     -C                        # some config file with another line
diff --git a/clap_complete_nushell/tests/snapshots/home/static/test/nu/.config/nushell/completions/test.nu b/clap_complete_nushell/tests/snapshots/home/static/test/nu/.config/nushell/completions/test.nu
index 03c5cd6bd1b..ac1e050f667 100644
--- a/clap_complete_nushell/tests/snapshots/home/static/test/nu/.config/nushell/completions/test.nu
+++ b/clap_complete_nushell/tests/snapshots/home/static/test/nu/.config/nushell/completions/test.nu
@@ -178,10 +178,10 @@ module completions {
     --choice: string@"nu-complete test hint choice"
     --unknown: string
     --other: string
-    --path(-p): string
-    --file(-f): string
-    --dir(-d): string
-    --exe(-e): string
+    --path(-p): path
+    --file(-f): path
+    --dir(-d): path
+    --exe(-e): path
     --cmd-name: string
     --cmd(-c): string
     command_with_args?: string
diff --git a/clap_complete_nushell/tests/snapshots/special_commands.nu b/clap_complete_nushell/tests/snapshots/special_commands.nu
index f74a3c867b4..0551531b3f7 100644
--- a/clap_complete_nushell/tests/snapshots/special_commands.nu
+++ b/clap_complete_nushell/tests/snapshots/special_commands.nu
@@ -6,7 +6,7 @@ module completions {
 
   # Tests completions
   export extern my-app [
-    file?: string             # some input file
+    file?: path               # some input file
     --config(-c)              # some config file with another line
     --conf                    # some config file with another line
     -C                        # some config file with another line
diff --git a/clap_complete_nushell/tests/snapshots/sub_subcommands.nu b/clap_complete_nushell/tests/snapshots/sub_subcommands.nu
index 7b0570f876a..2f56ca6d46c 100644
--- a/clap_complete_nushell/tests/snapshots/sub_subcommands.nu
+++ b/clap_complete_nushell/tests/snapshots/sub_subcommands.nu
@@ -6,7 +6,7 @@ module completions {
 
   # Tests completions
   export extern my-app [
-    file?: string             # some input file
+    file?: path               # some input file
     --config(-c)              # some config file with another line
     --conf                    # some config file with another line
     -C                        # some config file with another line
diff --git a/clap_complete_nushell/tests/snapshots/value_hint.nu b/clap_complete_nushell/tests/snapshots/value_hint.nu
index 2cc0b5ab800..f27849a5463 100644
--- a/clap_complete_nushell/tests/snapshots/value_hint.nu
+++ b/clap_complete_nushell/tests/snapshots/value_hint.nu
@@ -8,10 +8,10 @@ module completions {
     --choice: string@"nu-complete my-app choice"
     --unknown: string
     --other: string
-    --path(-p): string
-    --file(-f): string
-    --dir(-d): string
-    --exe(-e): string
+    --path(-p): path
+    --file(-f): path
+    --dir(-d): path
+    --exe(-e): path
     --cmd-name: string
     --cmd(-c): string
     command_with_args?: string