Skip to content

Commit 7e181ae

Browse files
0x61nasrami3l
authored andcommitted
fix(doc): don't show the opening message when --path is used
This might seem like a travel or unnecessary thing, especially since the message is written to `stderr` so it won't affect piping or similar use cases. But since `stdout` and `stderr` are ambiguous in most terminals (i.e., they're printed in the output) this might cause some confusion and/or annoyance to some users.
1 parent 4c4183d commit 7e181ae

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/cli/rustup_mode.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1594,18 +1594,15 @@ fn doc(cfg: &Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
15941594
};
15951595

15961596
let topical_path: PathBuf;
1597+
let mut doc_name = m.get_one::<String>("topic").map(|s| s.as_str());
15971598

1598-
let doc_url = if let Some(topic) = m.get_one::<String>("topic") {
1599+
let doc_url = if let Some(topic) = doc_name {
15991600
topical_path = topical_doc::local_path(&toolchain.doc_path("").unwrap(), topic)?;
16001601
topical_path.to_str().unwrap()
16011602
} else if let Some((name, _, path)) = DOCS_DATA.iter().find(|(name, _, _)| m.get_flag(name)) {
1602-
writeln!(
1603-
process().stderr().lock(),
1604-
"Opening docs named `{name}` in your browser"
1605-
)?;
1603+
doc_name = Some(name);
16061604
path
16071605
} else {
1608-
writeln!(process().stderr().lock(), "Opening docs in your browser")?;
16091606
"index.html"
16101607
};
16111608

@@ -1614,6 +1611,14 @@ fn doc(cfg: &Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
16141611
writeln!(process().stdout().lock(), "{}", doc_path.display())?;
16151612
Ok(utils::ExitCode(0))
16161613
} else {
1614+
if let Some(name) = doc_name {
1615+
writeln!(
1616+
process().stderr().lock(),
1617+
"Opening docs named `{name}` in your browser"
1618+
)?;
1619+
} else {
1620+
writeln!(process().stderr().lock(), "Opening docs in your browser")?;
1621+
}
16171622
toolchain.open_docs(doc_url)?;
16181623
Ok(utils::ExitCode(0))
16191624
}

0 commit comments

Comments
 (0)