Skip to content

Commit 21e7f7d

Browse files
committed
Add --toolchain option to 'rustup doc'
Fix #1477
1 parent 22b6cdb commit 21e7f7d

File tree

2 files changed

+9
-13
lines changed

2 files changed

+9
-13
lines changed

src/rustup-cli/rustup_mode.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,12 @@ pub fn cli() -> App<'static, 'static> {
389389
.long("reference")
390390
.help("The Rust Reference"),
391391
)
392+
.arg(
393+
Arg::with_name("toolchain")
394+
.help(TOOLCHAIN_ARG_HELP)
395+
.long("toolchain")
396+
.takes_value(true),
397+
)
392398
.group(ArgGroup::with_name("page").args(&["book", "std", "reference"])),
393399
);
394400

@@ -946,6 +952,7 @@ fn override_remove(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
946952
}
947953

948954
fn doc(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
955+
let toolchain = explicit_or_dir_toolchain(cfg, m)?;
949956
let doc_url = if m.is_present("book") {
950957
"book/index.html"
951958
} else if m.is_present("std") {
@@ -956,13 +963,12 @@ fn doc(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
956963
"index.html"
957964
};
958965

959-
let cwd = &utils::current_dir()?;
960966
if m.is_present("path") {
961-
let doc_path = try!(cfg.doc_path_for_dir(cwd, doc_url));
967+
let doc_path = toolchain.doc_path(doc_url)?;
962968
println!("{}", doc_path.display());
963969
Ok(())
964970
} else {
965-
Ok(cfg.open_docs_for_dir(cwd, doc_url)?)
971+
Ok(toolchain.open_docs(doc_url)?)
966972
}
967973
}
968974

src/rustup/config.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -467,16 +467,6 @@ impl Cfg {
467467
Ok(None)
468468
}
469469

470-
pub fn doc_path_for_dir(&self, path: &Path, relative: &str) -> Result<PathBuf> {
471-
let (toolchain, _) = self.toolchain_for_dir(path)?;
472-
toolchain.doc_path(relative)
473-
}
474-
475-
pub fn open_docs_for_dir(&self, path: &Path, relative: &str) -> Result<()> {
476-
let (toolchain, _) = self.toolchain_for_dir(path)?;
477-
toolchain.open_docs(relative)
478-
}
479-
480470
pub fn set_default_host_triple(&self, host_triple: &str) -> Result<()> {
481471
if dist::PartialTargetTriple::from_str(host_triple).is_none() {
482472
return Err("Invalid host triple".into());

0 commit comments

Comments
 (0)