Skip to content

Commit 72bb48a

Browse files
committed
Add --path option to 'rustup override set'
Same as --path in 'rustup override unset'
1 parent 9774f51 commit 72bb48a

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

src/rustup-cli/rustup_mode.rs

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustup_dist::manifest::Component;
77
use rustup_dist::dist::{PartialTargetTriple, PartialToolchainDesc, TargetTriple};
88
use rustup_utils::utils::{self, ExitCode};
99
use self_update;
10-
use std::path::Path;
10+
use std::path::{Path, PathBuf};
1111
use std::process::{self, Command};
1212
use std::iter;
1313
use std::error::Error;
@@ -316,6 +316,12 @@ pub fn cli() -> App<'static, 'static> {
316316
Arg::with_name("toolchain")
317317
.help(TOOLCHAIN_ARG_HELP)
318318
.required(true),
319+
)
320+
.arg(
321+
Arg::with_name("path")
322+
.long("path")
323+
.takes_value(true)
324+
.help("Path to the directory"),
319325
),
320326
)
321327
.subcommand(
@@ -899,7 +905,12 @@ fn override_add(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
899905
None
900906
};
901907

902-
toolchain.make_override(&utils::current_dir()?)?;
908+
let path = if let Some(path) = m.value_of("path") {
909+
PathBuf::from(path)
910+
} else {
911+
utils::current_dir()?
912+
};
913+
toolchain.make_override(&path)?;
903914

904915
if let Some(status) = status {
905916
println!("");
@@ -928,8 +939,8 @@ fn override_remove(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
928939
}
929940
list
930941
} else {
931-
if m.is_present("path") {
932-
vec![m.value_of("path").unwrap().to_string()]
942+
if let Some(path) = m.value_of("path") {
943+
vec![path.to_string()]
933944
} else {
934945
vec![utils::current_dir()?.to_str().unwrap().to_string()]
935946
}

0 commit comments

Comments
 (0)