Skip to content

Commit

Permalink
Add --path option to 'rustup override set'
Browse files Browse the repository at this point in the history
Same as --path in 'rustup override unset'
  • Loading branch information
pickfire committed Oct 9, 2018
1 parent 1e51b07 commit 5f8930e
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/rustup-cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use rustup_dist::manifest::Component;
use rustup_dist::dist::{PartialTargetTriple, PartialToolchainDesc, TargetTriple};
use rustup_utils::utils::{self, ExitCode};
use self_update;
use std::path::Path;
use std::path::{Path, PathBuf};
use std::process::{self, Command};
use std::iter;
use std::error::Error;
Expand Down Expand Up @@ -316,6 +316,12 @@ pub fn cli() -> App<'static, 'static> {
Arg::with_name("toolchain")
.help(TOOLCHAIN_ARG_HELP)
.required(true),
)
.arg(
Arg::with_name("path")
.long("path")
.takes_value(true)
.help("Path to the directory"),
),
)
.subcommand(
Expand Down Expand Up @@ -899,7 +905,12 @@ fn override_add(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
None
};

toolchain.make_override(&utils::current_dir()?)?;
let path = if let Some(path) = m.value_of("path") {
PathBuf::from(path)
} else {
utils::current_dir()?
};
toolchain.make_override(&path)?;

if let Some(status) = status {
println!("");
Expand Down Expand Up @@ -928,8 +939,8 @@ fn override_remove(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
}
list
} else {
if m.is_present("path") {
vec![m.value_of("path").unwrap().to_string()]
if let Some(path) = m.value_of("path") {
vec![path.to_string()]
} else {
vec![utils::current_dir()?.to_str().unwrap().to_string()]
}
Expand Down

0 comments on commit 5f8930e

Please sign in to comment.