Skip to content

Commit 388af5b

Browse files
authored
Merge pull request #82 from fornwall/cli-arguments
Polish cli parameters
2 parents 2db3739 + b5bb27f commit 388af5b

File tree

1 file changed

+12
-15
lines changed

1 file changed

+12
-15
lines changed

src/arguments.rs

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,9 @@ use crate::build_kind::BuildKind;
66
pub struct Args {
77
pub script: Option<String>,
88
pub script_args: Vec<String>,
9-
109
pub expr: bool,
1110
pub loop_: bool,
1211
pub count: bool,
13-
1412
pub pkg_path: Option<String>,
1513
pub gen_pkg_only: bool,
1614
pub cargo_output: bool,
@@ -21,12 +19,7 @@ pub struct Args {
2119
pub force: bool,
2220
pub unstable_features: Vec<String>,
2321
pub build_kind: BuildKind,
24-
// This is a String instead of an
25-
// enum since one can have custom
26-
// toolchains (ex. a rustc developer
27-
// will probably have `stage1`).
2822
pub toolchain_version: Option<String>,
29-
3023
#[cfg(windows)]
3124
pub install_file_association: bool,
3225
#[cfg(windows)]
@@ -80,7 +73,7 @@ impl Args {
8073
*/
8174
.arg(Arg::new("cargo-output")
8275
.help("Show output from cargo when building.")
83-
.short('o')
76+
.short('c')
8477
.long("cargo-output")
8578
.action(ArgAction::SetTrue)
8679
.requires("script")
@@ -97,7 +90,7 @@ impl Args {
9790
.action(ArgAction::SetTrue)
9891
)
9992
.arg(Arg::new("dep")
100-
.help("Add an additional Cargo dependency. Each SPEC can be either just the package name (which will assume the latest version) or a full `name=version` spec.")
93+
.help("Add a dependency - either just the package name (for the latest version) or as `name=version`.")
10194
.long("dep")
10295
.short('d')
10396
.num_args(1..)
@@ -124,17 +117,20 @@ impl Args {
124117
.arg(Arg::new("clear-cache")
125118
.help("Clears out the script cache.")
126119
.long("clear-cache")
120+
.exclusive(true)
127121
.action(ArgAction::SetTrue),
128122
)
129123
.arg(Arg::new("force")
130124
.help("Force the script to be rebuilt.")
131125
.long("force")
126+
.short('f')
132127
.action(ArgAction::SetTrue)
133128
.requires("script")
134129
)
135130
.arg(Arg::new("gen_pkg_only")
136-
.help("Generate the Cargo package, but don't compile or run it.")
131+
.help("Generate the Cargo package and print the path to it, but don't compile or run it.")
137132
.long("project")
133+
.short('p')
138134
.action(ArgAction::SetTrue)
139135
.requires("script")
140136
.conflicts_with_all(["debug", "force", "test", "bench"])
@@ -158,11 +154,10 @@ impl Args {
158154
.action(ArgAction::SetTrue)
159155
.conflicts_with_all(["test", "debug", "force"])
160156
)
161-
.arg(Arg::new("toolchain-version")
157+
.arg(Arg::new("toolchain")
162158
.help("Build the script using the given toolchain version.")
163-
.long("toolchain-version")
164-
// "channel"
165-
.short('c')
159+
.long("toolchain")
160+
.short('t')
166161
.num_args(1)
167162
// Benchmarking currently requires nightly:
168163
.conflicts_with("bench")
@@ -174,6 +169,7 @@ impl Args {
174169
Arg::new("install-file-association")
175170
.help("Install a file association so that rust-script executes .ers files.")
176171
.long("install-file-association")
172+
.exclusive(true)
177173
.action(ArgAction::SetTrue),
178174
)
179175
.arg(
@@ -182,6 +178,7 @@ impl Args {
182178
"Uninstall the file association that makes rust-script execute .ers files.",
183179
)
184180
.long("uninstall-file-association")
181+
.exclusive(true)
185182
.action(ArgAction::SetTrue),
186183
)
187184
.group(
@@ -235,7 +232,7 @@ impl Args {
235232
.map(|values| values.collect())
236233
.unwrap_or_default(),
237234
build_kind: BuildKind::from_flags(m.get_flag("test"), m.get_flag("bench")),
238-
toolchain_version: m.get_one::<String>("toolchain-version").map(Into::into),
235+
toolchain_version: m.get_one::<String>("toolchain").map(Into::into),
239236
#[cfg(windows)]
240237
install_file_association: m.get_flag("install-file-association"),
241238
#[cfg(windows)]

0 commit comments

Comments
 (0)