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 Feb 2, 2019
1 parent b697df1 commit 8944f27
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 @@ -12,7 +12,7 @@ use rustup_utils::utils::{self, ExitCode};
use std::error::Error;
use std::io::{self, Write};
use std::iter;
use std::path::Path;
use std::path::{Path, PathBuf};
use std::process::{self, Command};

pub fn main() -> Result<()> {
Expand Down Expand Up @@ -341,6 +341,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 @@ -913,7 +919,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 @@ -942,8 +953,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 8944f27

Please sign in to comment.