Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --toolchain option to 'rustup doc' #1478

Merged
merged 2 commits into from
Sep 13, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/rustup-cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,12 @@ pub fn cli() -> App<'static, 'static> {
.long("reference")
.help("The Rust Reference"),
)
.arg(
Arg::with_name("toolchain")
.help(TOOLCHAIN_ARG_HELP)
.long("toolchain")
.takes_value(true),
)
.group(ArgGroup::with_name("page").args(&["book", "std", "reference"])),
);

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

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

let cwd = &utils::current_dir()?;
if m.is_present("path") {
let doc_path = try!(cfg.doc_path_for_dir(cwd, doc_url));
let doc_path = toolchain.doc_path(doc_url)?;
println!("{}", doc_path.display());
Ok(())
} else {
Ok(cfg.open_docs_for_dir(cwd, doc_url)?)
Ok(toolchain.open_docs(doc_url)?)
}
}

Expand Down
10 changes: 0 additions & 10 deletions src/rustup/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -467,16 +467,6 @@ impl Cfg {
Ok(None)
}

pub fn doc_path_for_dir(&self, path: &Path, relative: &str) -> Result<PathBuf> {
let (toolchain, _) = self.toolchain_for_dir(path)?;
toolchain.doc_path(relative)
}

pub fn open_docs_for_dir(&self, path: &Path, relative: &str) -> Result<()> {
let (toolchain, _) = self.toolchain_for_dir(path)?;
toolchain.open_docs(relative)
}

pub fn set_default_host_triple(&self, host_triple: &str) -> Result<()> {
if dist::PartialTargetTriple::from_str(host_triple).is_none() {
return Err("Invalid host triple".into());
Expand Down