about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-12-23 19:31:58 +0000
committerbors <bors@rust-lang.org>2024-12-23 19:31:58 +0000
commitbdc6b3de48646345549fd2fe9f62370f56e3fa56 (patch)
tree41b83953e4f4c9c99424fafbeba57463b6ea1bb9 /src/bootstrap
parentaddbd001ec56741829f20a3000892f8620dd0843 (diff)
parentbc1737b279dd8382e4f613f36e74552ee76a3c01 (diff)
downloadrust-bdc6b3de48646345549fd2fe9f62370f56e3fa56.tar.gz
rust-bdc6b3de48646345549fd2fe9f62370f56e3fa56.zip
Auto merge of #134405 - rmehri01:x-completions, r=onur-ozkan
Generate shell completions for x as well

It would be nice to be have shell completions for both `./x` and `x` (installed with `cargo install --path src/tools/x`) instead of just `x.py`. This pr generates the corresponding completions for each shell in a similar way to `x.py` but under `x.<shell>` instead.
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/src/core/build_steps/run.rs6
-rw-r--r--src/bootstrap/src/core/config/flags.rs9
2 files changed, 13 insertions, 2 deletions
diff --git a/src/bootstrap/src/core/build_steps/run.rs b/src/bootstrap/src/core/build_steps/run.rs
index c76504761be..54aad088552 100644
--- a/src/bootstrap/src/core/build_steps/run.rs
+++ b/src/bootstrap/src/core/build_steps/run.rs
@@ -270,7 +270,11 @@ impl Step for GenerateCompletions {
             (Bash, builder.src.join("src/etc/completions/x.py.sh")),
             (Zsh, builder.src.join("src/etc/completions/x.py.zsh")),
             (Fish, builder.src.join("src/etc/completions/x.py.fish")),
-            (PowerShell, builder.src.join("src/etc/completions/x.py.ps1"))
+            (PowerShell, builder.src.join("src/etc/completions/x.py.ps1")),
+            (Bash, builder.src.join("src/etc/completions/x.sh")),
+            (Zsh, builder.src.join("src/etc/completions/x.zsh")),
+            (Fish, builder.src.join("src/etc/completions/x.fish")),
+            (PowerShell, builder.src.join("src/etc/completions/x.ps1"))
         );
     }
 
diff --git a/src/bootstrap/src/core/config/flags.rs b/src/bootstrap/src/core/config/flags.rs
index bfeb811508c..00bcbe9f86d 100644
--- a/src/bootstrap/src/core/config/flags.rs
+++ b/src/bootstrap/src/core/config/flags.rs
@@ -633,7 +633,14 @@ pub fn get_completion<G: clap_complete::Generator>(shell: G, path: &Path) -> Opt
         })
     };
     let mut buf = Vec::new();
-    clap_complete::generate(shell, &mut cmd, "x.py", &mut buf);
+    let (bin_name, _) = path
+        .file_name()
+        .expect("path should be a regular file")
+        .to_str()
+        .expect("file name should be UTF-8")
+        .rsplit_once('.')
+        .expect("file name should have an extension");
+    clap_complete::generate(shell, &mut cmd, bin_name, &mut buf);
     if buf == current.as_bytes() {
         return None;
     }