Skip to content

Commit 0084ef6

Browse files
committed
chore: resolve clap 3 deprecated api
1 parent 0589827 commit 0084ef6

File tree

6 files changed

+10
-18
lines changed

6 files changed

+10
-18
lines changed

src/cli.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ use volta_core::session::Session;
1212
1313
To install a tool in your toolchain, use `volta install`.
1414
To pin your project's runtime or package manager, use `volta pin`.",
15-
global_setting = clap::AppSettings::ColoredHelp,
16-
global_setting = clap::AppSettings::ColorAuto,
15+
color = clap::ColorChoice::Auto,
1716
global_setting = clap::AppSettings::DeriveDisplayOrder,
18-
global_setting = clap::AppSettings::DisableVersion,
19-
global_setting = clap::AppSettings::DontCollapseArgsInUsage,
17+
disable_version_flag = true,
18+
dont_collapse_args_in_usage = true,
2019
)]
2120
pub(crate) struct Volta {
2221
#[clap(subcommand)]
@@ -55,7 +54,7 @@ impl Volta {
5554
} else if let Some(command) = self.command {
5655
command.run(session)
5756
} else {
58-
Volta::from_iter(["volta", "help"].iter()).run(session)
57+
Volta::parse_from(["volta", "help"].iter()).run(session)
5958
}
6059
}
6160
}
@@ -85,7 +84,7 @@ pub(crate) enum Subcommand {
8584
/// Generates Volta completions
8685
#[clap(
8786
name = "completions",
88-
setting = clap::AppSettings::ArgRequiredElseHelp,
87+
arg_required_else_help = true,
8988
long_about = "Generates Volta completions
9089
9190
By default, completions will be generated for the value of your current shell,
@@ -105,7 +104,7 @@ otherwise, they will be written to `stdout`.
105104
#[clap(
106105
name = "use",
107106
long_about = crate::command::r#use::USAGE,
108-
setting = clap::AppSettings::Hidden,
107+
hide = true,
109108
)]
110109
Use(command::Use),
111110

@@ -114,11 +113,7 @@ otherwise, they will be written to `stdout`.
114113
Setup(command::Setup),
115114

116115
/// Run a command with custom Node, npm, pnpm, and/or Yarn versions
117-
#[clap(
118-
name = "run",
119-
setting = clap::AppSettings::AllowLeadingHyphen,
120-
setting = clap::AppSettings::TrailingVarArg,
121-
)]
116+
#[clap(name = "run", allow_hyphen_values = true, trailing_var_arg = true)]
122117
Run(command::Run),
123118
}
124119

src/command/completions.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::command::Command;
1515
#[derive(Debug, clap::Args)]
1616
pub(crate) struct Completions {
1717
/// Shell to generate completions for
18-
#[clap(takes_value = true, index = 1, case_insensitive = true)]
18+
#[clap(takes_value = true, index = 1, ignore_case = true)]
1919
shell: Shell,
2020

2121
/// File to write generated completions to

src/command/list/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ pub(crate) struct List {
211211
/// Specify the output format.
212212
///
213213
/// Defaults to `human` for TTYs, `plain` otherwise.
214-
#[clap(long = "format", possible_values = &["human", "plain"])]
214+
#[clap(long = "format", value_parser = ["human", "plain"])]
215215
format: Option<Format>,
216216

217217
/// Show the currently-active tool(s).

src/command/run.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,9 @@ pub(crate) struct Run {
4444
#[clap(long = "env", value_name = "NAME=value", number_of_values = 1)]
4545
envs: Vec<String>,
4646

47-
#[clap(parse(from_os_str))]
4847
/// The command to run
4948
command: OsString,
5049

51-
#[clap(parse(from_os_str))]
5250
/// Arguments to pass to the command
5351
args: Vec<OsString>,
5452
}

src/command/which.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ use crate::command::Command;
1313
#[derive(clap::Args)]
1414
pub(crate) struct Which {
1515
/// The binary to find, e.g. `node` or `npm`
16-
#[clap(parse(from_os_str))]
1716
binary: OsString,
1817
}
1918

src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use common::{ensure_layout, Error};
1313

1414
/// The entry point for the `volta` CLI.
1515
pub fn main() {
16-
let volta = cli::Volta::from_args();
16+
let volta = cli::Volta::parse();
1717
let verbosity = match (&volta.verbose, &volta.quiet) {
1818
(false, false) => LogVerbosity::Default,
1919
(true, false) => LogVerbosity::Verbose,

0 commit comments

Comments
 (0)