Skip to content

Commit bdc6b3d

Browse files
committed
Auto merge of rust-lang#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.
2 parents addbd00 + bc1737b commit bdc6b3d

File tree

6 files changed

+5952
-2
lines changed

6 files changed

+5952
-2
lines changed

Diff for: src/bootstrap/src/core/build_steps/run.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,11 @@ impl Step for GenerateCompletions {
270270
(Bash, builder.src.join("src/etc/completions/x.py.sh")),
271271
(Zsh, builder.src.join("src/etc/completions/x.py.zsh")),
272272
(Fish, builder.src.join("src/etc/completions/x.py.fish")),
273-
(PowerShell, builder.src.join("src/etc/completions/x.py.ps1"))
273+
(PowerShell, builder.src.join("src/etc/completions/x.py.ps1")),
274+
(Bash, builder.src.join("src/etc/completions/x.sh")),
275+
(Zsh, builder.src.join("src/etc/completions/x.zsh")),
276+
(Fish, builder.src.join("src/etc/completions/x.fish")),
277+
(PowerShell, builder.src.join("src/etc/completions/x.ps1"))
274278
);
275279
}
276280

Diff for: src/bootstrap/src/core/config/flags.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,14 @@ pub fn get_completion<G: clap_complete::Generator>(shell: G, path: &Path) -> Opt
633633
})
634634
};
635635
let mut buf = Vec::new();
636-
clap_complete::generate(shell, &mut cmd, "x.py", &mut buf);
636+
let (bin_name, _) = path
637+
.file_name()
638+
.expect("path should be a regular file")
639+
.to_str()
640+
.expect("file name should be UTF-8")
641+
.rsplit_once('.')
642+
.expect("file name should have an extension");
643+
clap_complete::generate(shell, &mut cmd, bin_name, &mut buf);
637644
if buf == current.as_bytes() {
638645
return None;
639646
}

0 commit comments

Comments
 (0)