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 authored and dwijnand committed Mar 17, 2019
1 parent 819ddda commit 92c9bc7
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use rustup::{command, Cfg, Toolchain};
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};

fn handle_epipe(res: Result<()>) -> Result<()> {
Expand Down Expand Up @@ -348,6 +348,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 @@ -929,7 +935,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 @@ -958,8 +969,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 92c9bc7

Please sign in to comment.