Skip to content

Commit 7e19a08

Browse files
authored
chore: deprecate generate-fig-spec commands; use completions fig (#11727)
* chore: deprecate `generate-fig-spec` commands; use `completions fig` instead * fix: use `sh_eprintln` to make clippy happy
1 parent 3f0e871 commit 7e19a08

File tree

12 files changed

+41
-26
lines changed

12 files changed

+41
-26
lines changed

Cargo.lock

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/anvil/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ clap_complete = { workspace = true, optional = true}
106106
chrono.workspace = true
107107
ctrlc = { version = "3", optional = true }
108108
fdlimit = { version = "0.3", optional = true }
109-
clap_complete_fig = "4"
110109

111110
[dev-dependencies]
112111
alloy-provider = { workspace = true, features = ["txpool-api"] }

crates/anvil/src/args.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,17 @@ pub fn run_command(args: Anvil) -> Result<()> {
3333
&mut std::io::stdout(),
3434
);
3535
}
36-
AnvilSubcommand::GenerateFigSpec => clap_complete::generate(
37-
clap_complete_fig::Fig,
38-
&mut Anvil::command(),
39-
"anvil",
40-
&mut std::io::stdout(),
41-
),
36+
AnvilSubcommand::GenerateFigSpec => {
37+
clap_complete::generate(
38+
foundry_common::clap::Shell::Fig,
39+
&mut Anvil::command(),
40+
"anvil",
41+
&mut std::io::stdout(),
42+
);
43+
sh_eprintln!(
44+
"[deprecated] `anvil generate-fig-spec` is deprecated; use `anvil completions fig`"
45+
)?;
46+
}
4247
}
4348
return Ok(());
4449
}

crates/anvil/src/opts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub enum AnvilSubcommand {
2727
shell: foundry_common::clap::Shell,
2828
},
2929

30-
/// Generate Fig autocompletion spec.
31-
#[command(visible_alias = "fig")]
30+
/// Generate Fig autocompletion spec. Deprecated: use `anvil completions fig` instead.
31+
#[command(visible_alias = "fig", hide = true)]
3232
GenerateFigSpec,
3333
}

crates/cast/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ foundry-cli.workspace = true
7373

7474
clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] }
7575
clap_complete.workspace = true
76-
clap_complete_fig = "4"
7776
comfy-table.workspace = true
7877
dunce.workspace = true
7978
itertools.workspace = true

crates/cast/src/args.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -729,12 +729,17 @@ pub async fn run_command(args: CastArgs) -> Result<()> {
729729
CastSubcommand::Completions { shell } => {
730730
generate(shell, &mut CastArgs::command(), "cast", &mut std::io::stdout())
731731
}
732-
CastSubcommand::GenerateFigSpec => clap_complete::generate(
733-
clap_complete_fig::Fig,
734-
&mut CastArgs::command(),
735-
"cast",
736-
&mut std::io::stdout(),
737-
),
732+
CastSubcommand::GenerateFigSpec => {
733+
generate(
734+
foundry_common::clap::Shell::Fig,
735+
&mut CastArgs::command(),
736+
"cast",
737+
&mut std::io::stdout(),
738+
);
739+
sh_eprintln!(
740+
"[deprecated] `cast generate-fig-spec` is deprecated; use `cast completions fig`"
741+
)?;
742+
}
738743
CastSubcommand::Logs(cmd) => cmd.run().await?,
739744
CastSubcommand::DecodeTransaction { tx } => {
740745
let tx = stdin::unwrap_line(tx)?;

crates/cast/src/opts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,8 +1079,8 @@ pub enum CastSubcommand {
10791079
shell: foundry_common::clap::Shell,
10801080
},
10811081

1082-
/// Generate Fig autocompletion spec.
1083-
#[command(visible_alias = "fig")]
1082+
/// Generate Fig autocompletion spec. Deprecated: use `cast completions fig` instead.
1083+
#[command(visible_alias = "fig", hide = true)]
10841084
GenerateFigSpec,
10851085

10861086
/// Runs a published transaction in a local environment and prints the trace.

crates/common/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ tower.workspace = true
5353
clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] }
5454
clap_complete.workspace = true
5555
clap_complete_nushell.workspace = true
56+
clap_complete_fig = "4"
5657
comfy-table.workspace = true
5758
dunce.workspace = true
5859
eyre.workspace = true

crates/common/src/clap.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
use clap_complete::{Shell as ClapCompleteShell, aot::Generator};
2+
use clap_complete_fig::Fig as ClapFig;
23
use clap_complete_nushell::Nushell;
34

45
#[derive(Clone, Copy)]
56
pub enum Shell {
67
ClapCompleteShell(ClapCompleteShell),
78
Nushell,
9+
Fig,
810
}
911

1012
impl clap::ValueEnum for Shell {
@@ -16,13 +18,15 @@ impl clap::ValueEnum for Shell {
1618
Self::ClapCompleteShell(ClapCompleteShell::PowerShell),
1719
Self::ClapCompleteShell(ClapCompleteShell::Elvish),
1820
Self::Nushell,
21+
Self::Fig,
1922
]
2023
}
2124

2225
fn to_possible_value(&self) -> Option<clap::builder::PossibleValue> {
2326
match self {
2427
Self::ClapCompleteShell(shell) => shell.to_possible_value(),
2528
Self::Nushell => Some(clap::builder::PossibleValue::new("nushell")),
29+
Self::Fig => Some(clap::builder::PossibleValue::new("fig")),
2630
}
2731
}
2832
}
@@ -32,13 +36,15 @@ impl Generator for Shell {
3236
match self {
3337
Self::ClapCompleteShell(shell) => shell.file_name(name),
3438
Self::Nushell => Nushell.file_name(name),
39+
Self::Fig => ClapFig.file_name(name),
3540
}
3641
}
3742

3843
fn generate(&self, cmd: &clap::Command, buf: &mut dyn std::io::Write) {
3944
match self {
4045
Self::ClapCompleteShell(shell) => shell.generate(cmd, buf),
4146
Self::Nushell => Nushell.generate(cmd, buf),
47+
Self::Fig => ClapFig.generate(cmd, buf),
4248
}
4349
}
4450
}

crates/forge/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ revm.workspace = true
6767

6868
clap = { version = "4", features = ["derive", "env", "unicode", "wrap_help"] }
6969
clap_complete.workspace = true
70-
clap_complete_fig = "4"
7170
dunce.workspace = true
7271
indicatif.workspace = true
7372
inferno = { version = "0.12", default-features = false }

0 commit comments

Comments
 (0)