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 Apr 15, 2019
1 parent 4017736 commit 1e6e08b
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use std::error::Error;
use std::fmt;
use std::io::Write;
use std::iter;
use std::path::Path;
use std::path::{Path, PathBuf};
use std::process::{self, Command};
use std::str::FromStr;

Expand Down Expand Up @@ -351,6 +351,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 @@ -992,7 +998,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
29 changes: 29 additions & 0 deletions tests/cli-rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,35 @@ fn show_toolchain_override_not_installed() {
});
}

#[test]
fn override_set_unset_with_path() {
setup(&|config| {
let workdir = config.current_dir();
let workdir = workdir.to_string_lossy();
config.change_dir(&config.emptydir, &|| {
expect_ok(
config,
&["rustup", "override", "set", "nightly", "--path", &workdir],
);
});
expect_ok_ex(
config,
&["rustup", "override", "list"],
&format!("{}\tnightly-x86_64-unknown-linux-gnu\n", &workdir),
r"",
);
config.change_dir(&config.emptydir, &|| {
expect_ok(config, &["rustup", "override", "unset", "--path", &workdir]);
});
expect_ok_ex(
config,
&["rustup", "override", "list"],
&"no overrides\n",
r"",
);
});
}

#[test]
fn show_toolchain_env() {
setup(&|config| {
Expand Down

0 comments on commit 1e6e08b

Please sign in to comment.