Skip to content

Commit 4718607

Browse files
committed
chore: resolve clap 4 deprecated api
1 parent 0b29efb commit 4718607

File tree

7 files changed

+34
-34
lines changed

7 files changed

+34
-34
lines changed

src/cli.rs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use volta_core::error::{ExitCode, Fallible};
55
use volta_core::session::Session;
66

77
#[derive(Parser)]
8-
#[clap(
8+
#[command(
99
name = "Volta",
1010
about = "The JavaScript Launcher ⚡",
1111
long_about = "The JavaScript Launcher ⚡
@@ -14,16 +14,15 @@ use volta_core::session::Session;
1414
To pin your project's runtime or package manager, use `volta pin`.",
1515
color = clap::ColorChoice::Auto,
1616
disable_version_flag = true,
17-
dont_collapse_args_in_usage = true,
1817
)]
1918
pub(crate) struct Volta {
20-
#[clap(subcommand)]
19+
#[command(subcommand)]
2120
pub(crate) command: Option<Subcommand>,
2221

23-
#[clap(long = "verbose", help = "Enables verbose diagnostics", global = true)]
22+
#[arg(long = "verbose", help = "Enables verbose diagnostics", global = true)]
2423
pub(crate) verbose: bool,
2524

26-
#[clap(
25+
#[arg(
2726
long = "quiet",
2827
help = "Prevents unnecessary output",
2928
global = true,
@@ -32,7 +31,7 @@ pub(crate) struct Volta {
3231
)]
3332
pub(crate) quiet: bool,
3433

35-
#[clap(
34+
#[arg(
3635
short = 'v',
3736
long = "version",
3837
help = "Prints the current version of Volta"
@@ -61,27 +60,27 @@ impl Volta {
6160
#[derive(clap::Subcommand)]
6261
pub(crate) enum Subcommand {
6362
/// Fetches a tool to the local machine
64-
#[clap(name = "fetch")]
63+
#[command(name = "fetch")]
6564
Fetch(command::Fetch),
6665

6766
/// Installs a tool in your toolchain
68-
#[clap(name = "install")]
67+
#[command(name = "install")]
6968
Install(command::Install),
7069

7170
/// Uninstalls a tool from your toolchain
72-
#[clap(name = "uninstall")]
71+
#[command(name = "uninstall")]
7372
Uninstall(command::Uninstall),
7473

7574
/// Pins your project's runtime or package manager
76-
#[clap(name = "pin")]
75+
#[command(name = "pin")]
7776
Pin(command::Pin),
7877

7978
/// Displays the current toolchain
80-
#[clap(name = "list", alias = "ls")]
79+
#[command(name = "list", alias = "ls")]
8180
List(command::List),
8281

8382
/// Generates Volta completions
84-
#[clap(
83+
#[command(
8584
name = "completions",
8685
arg_required_else_help = true,
8786
long_about = "Generates Volta completions
@@ -97,22 +96,22 @@ otherwise, they will be written to `stdout`.
9796
Completions(command::Completions),
9897

9998
/// Locates the actual binary that will be called by Volta
100-
#[clap(name = "which")]
99+
#[command(name = "which")]
101100
Which(command::Which),
102101

103-
#[clap(
102+
#[command(
104103
name = "use",
105104
long_about = crate::command::r#use::USAGE,
106105
hide = true,
107106
)]
108107
Use(command::Use),
109108

110109
/// Enables Volta for the current user / shell
111-
#[clap(name = "setup")]
110+
#[command(name = "setup")]
112111
Setup(command::Setup),
113112

114113
/// Run a command with custom Node, npm, pnpm, and/or Yarn versions
115-
#[clap(name = "run", allow_hyphen_values = true, trailing_var_arg = true)]
114+
#[command(name = "run")]
116115
Run(command::Run),
117116
}
118117

src/command/completions.rs

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

2121
/// File to write generated completions to
22-
#[clap(short = 'o', long = "output")]
22+
#[arg(short = 'o', long = "output")]
2323
out_file: Option<PathBuf>,
2424

2525
/// Write over an existing file, if any.
26-
#[clap(short = 'f', long = "force")]
26+
#[arg(short = 'f', long = "force")]
2727
force: bool,
2828
}
2929

src/command/fetch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::command::Command;
77
#[derive(clap::Args)]
88
pub(crate) struct Fetch {
99
/// Tools to fetch, like `node`, `yarn@latest` or `your-package@^14.4.3`.
10-
#[clap(name = "tool[@version]", required = true)]
10+
#[arg(value_name = "tool[@version]", required = true)]
1111
tools: Vec<String>,
1212
}
1313

src/command/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::command::Command;
77
#[derive(clap::Args)]
88
pub(crate) struct Install {
99
/// Tools to install, like `node`, `yarn@latest` or `your-package@^14.4.3`.
10-
#[clap(name = "tool[@version]", required = true)]
10+
#[arg(value_name = "tool[@version]", required = true)]
1111
tools: Vec<String>,
1212
}
1313

src/command/list/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,23 +205,23 @@ pub(crate) struct List {
205205
// variants (as detailed in commit 5f9214ae).
206206
/// The tool to lookup - `all`, `node`, `npm`, `yarn`, `pnpm`, or the name
207207
/// of a package or binary.
208-
#[clap(name = "tool")]
208+
#[arg(value_name = "tool")]
209209
subcommand: Option<String>,
210210

211211
/// Specify the output format.
212212
///
213213
/// Defaults to `human` for TTYs, `plain` otherwise.
214-
#[clap(long = "format", value_parser = ["human", "plain"])]
214+
#[arg(long = "format", value_parser = ["human", "plain"])]
215215
format: Option<Format>,
216216

217217
/// Show the currently-active tool(s).
218218
///
219219
/// Equivalent to `volta list` when not specifying a specific tool.
220-
#[clap(long = "current", short = 'c', conflicts_with = "default")]
220+
#[arg(long = "current", short = 'c', conflicts_with = "default")]
221221
current: bool,
222222

223223
/// Show your default tool(s).
224-
#[clap(long = "default", short = 'd', conflicts_with = "current")]
224+
#[arg(long = "default", short = 'd', conflicts_with = "current")]
225225
default: bool,
226226
}
227227

src/command/pin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::command::Command;
77
#[derive(clap::Args)]
88
pub(crate) struct Pin {
99
/// Tools to pin, like `node@lts` or `yarn@^1.14`.
10-
#[clap(name = "tool[@version]", required = true)]
10+
#[arg(value_name = "tool[@version]", required = true)]
1111
tools: Vec<String>,
1212
}
1313

src/command/run.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,41 +13,42 @@ use volta_core::tool::{node, npm, pnpm, yarn};
1313
#[derive(Debug, clap::Args)]
1414
pub(crate) struct Run {
1515
/// Set the custom Node version
16-
#[clap(long = "node", value_name = "version")]
16+
#[arg(long = "node", value_name = "version")]
1717
node: Option<String>,
1818

1919
/// Set the custom npm version
20-
#[clap(long = "npm", value_name = "version", conflicts_with = "bundled_npm")]
20+
#[arg(long = "npm", value_name = "version", conflicts_with = "bundled_npm")]
2121
npm: Option<String>,
2222

2323
/// Forces npm to be the version bundled with Node
24-
#[clap(long = "bundled-npm", conflicts_with = "npm")]
24+
#[arg(long = "bundled-npm", conflicts_with = "npm")]
2525
bundled_npm: bool,
2626

2727
/// Set the custon pnpm version
28-
#[clap(long = "pnpm", value_name = "version", conflicts_with = "no_pnpm")]
28+
#[arg(long = "pnpm", value_name = "version", conflicts_with = "no_pnpm")]
2929
pnpm: Option<String>,
3030

3131
/// Disables pnpm
32-
#[clap(long = "no-pnpm", conflicts_with = "pnpm")]
32+
#[arg(long = "no-pnpm", conflicts_with = "pnpm")]
3333
no_pnpm: bool,
3434

3535
/// Set the custom Yarn version
36-
#[clap(long = "yarn", value_name = "version", conflicts_with = "no_yarn")]
36+
#[arg(long = "yarn", value_name = "version", conflicts_with = "no_yarn")]
3737
yarn: Option<String>,
3838

3939
/// Disables Yarn
40-
#[clap(long = "no-yarn", conflicts_with = "yarn")]
40+
#[arg(long = "no-yarn", conflicts_with = "yarn")]
4141
no_yarn: bool,
4242

4343
/// Set an environment variable (can be used multiple times)
44-
#[clap(long = "env", value_name = "NAME=value", number_of_values = 1)]
44+
#[arg(long = "env", value_name = "NAME=value", num_args = 1)]
4545
envs: Vec<String>,
4646

4747
/// The command to run
4848
command: OsString,
4949

5050
/// Arguments to pass to the command
51+
#[arg(allow_hyphen_values = true, trailing_var_arg = true)]
5152
args: Vec<OsString>,
5253
}
5354

0 commit comments

Comments
 (0)