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 --path flag to 'rustup doc' #1311

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
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: 11 additions & 1 deletion src/rustup-cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,9 @@ pub fn cli() -> App<'static, 'static> {
.alias("docs")
.about("Open the documentation for the current toolchain")
.after_help(DOC_HELP)
.arg(Arg::with_name("path")
.long("path")
.help("Only print the path to the documentation"))
.arg(Arg::with_name("book")
.long("book")
.help("The Rust Programming Language book"))
Expand Down Expand Up @@ -788,7 +791,14 @@ fn doc(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
"index.html"
};

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

fn man(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
Expand Down
1 change: 1 addition & 0 deletions src/rustup/toolchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,6 +440,7 @@ impl<'a> Toolchain<'a> {

Ok(doc_dir)
}

pub fn open_docs(&self, relative: &str) -> Result<()> {
try!(self.verify());

Expand Down