diff options
| author | The Miri Conjob Bot <miri@cron.bot> | 2023-10-17 05:05:07 +0000 |
|---|---|---|
| committer | The Miri Conjob Bot <miri@cron.bot> | 2023-10-17 05:05:07 +0000 |
| commit | 2ca415c1c2fc7991027a1cfa332e305b4f27a0f8 (patch) | |
| tree | a072b8ca50207f8ed55e085580de73b0e37802f3 /src/bootstrap/run.rs | |
| parent | 8fa1b6aad2bd14fa2477daf8eeab69464e8878a5 (diff) | |
| parent | eccc9e66287d5fd141e458ae3ab25ac96a567972 (diff) | |
| download | rust-2ca415c1c2fc7991027a1cfa332e305b4f27a0f8.tar.gz rust-2ca415c1c2fc7991027a1cfa332e305b4f27a0f8.zip | |
Merge from rustc
Diffstat (limited to 'src/bootstrap/run.rs')
| -rw-r--r-- | src/bootstrap/run.rs | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/src/bootstrap/run.rs b/src/bootstrap/run.rs index 4082f5bb9b1..f253f5225a1 100644 --- a/src/bootstrap/run.rs +++ b/src/bootstrap/run.rs @@ -1,8 +1,6 @@ use std::path::PathBuf; use std::process::Command; -use clap_complete::shells; - use crate::builder::{Builder, RunConfig, ShouldRun, Step}; use crate::config::TargetSelection; use crate::dist::distdir; @@ -268,23 +266,29 @@ impl Step for GenerateWindowsSys { #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub struct GenerateCompletions; +macro_rules! generate_completions { + ( $( ( $shell:ident, $filename:expr ) ),* ) => { + $( + if let Some(comp) = get_completion($shell, &$filename) { + std::fs::write(&$filename, comp).expect(&format!("writing {} completion", stringify!($shell))); + } + )* + }; +} + impl Step for GenerateCompletions { type Output = (); /// Uses `clap_complete` to generate shell completions. fn run(self, builder: &Builder<'_>) { - // FIXME(clubby789): enable zsh when clap#4898 is fixed - let [bash, fish, powershell] = ["x.py.sh", "x.py.fish", "x.py.ps1"] - .map(|filename| builder.src.join("src/etc/completions").join(filename)); - if let Some(comp) = get_completion(shells::Bash, &bash) { - std::fs::write(&bash, comp).expect("writing bash completion"); - } - if let Some(comp) = get_completion(shells::Fish, &fish) { - std::fs::write(&fish, comp).expect("writing fish completion"); - } - if let Some(comp) = get_completion(shells::PowerShell, &powershell) { - std::fs::write(&powershell, comp).expect("writing powershell completion"); - } + use clap_complete::shells::{Bash, Fish, PowerShell, Zsh}; + + generate_completions!( + (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")) + ); } fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> { |
