Skip to content

Commit 2d5a070

Browse files
joerivanruthda-x
authored andcommitted
Add --path flag to 'rustup doc'
1 parent bb6f65f commit 2d5a070

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/rustup-cli/rustup_mode.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,11 @@ pub fn cli() -> App<'static, 'static> {
360360
.alias("docs")
361361
.about("Open the documentation for the current toolchain")
362362
.after_help(DOC_HELP)
363+
.arg(
364+
Arg::with_name("path")
365+
.long("path")
366+
.help("Only print the path to the documentation"),
367+
)
363368
.arg(
364369
Arg::with_name("book")
365370
.long("book")
@@ -929,7 +934,14 @@ fn doc(cfg: &Cfg, m: &ArgMatches) -> Result<()> {
929934
"index.html"
930935
};
931936

932-
Ok(cfg.open_docs_for_dir(&utils::current_dir()?, doc_url)?)
937+
let cwd = &utils::current_dir()?;
938+
if m.is_present("path") {
939+
let doc_path = try!(cfg.doc_path_for_dir(cwd, doc_url));
940+
println!("{}", doc_path.display());
941+
Ok(())
942+
} else {
943+
Ok(cfg.open_docs_for_dir(cwd, doc_url)?)
944+
}
933945
}
934946

935947
fn man(cfg: &Cfg, m: &ArgMatches) -> Result<()> {

0 commit comments

Comments
 (0)