Skip to content

Commit

Permalink
fix(doc): don't show the opening message when --path is used
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
0x61nas committed Mar 29, 2024
1 parent 0c501d5 commit 7f4372e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/cli/rustup_mode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1594,18 +1594,15 @@ fn doc(cfg: &Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
};

let topical_path: PathBuf;
let mut topic_name = None;

let doc_url = if let Some(topic) = m.get_one::<String>("topic") {
topical_path = topical_doc::local_path(&toolchain.doc_path("").unwrap(), topic)?;
topical_path.to_str().unwrap()
} else if let Some((name, _, path)) = DOCS_DATA.iter().find(|(name, _, _)| m.get_flag(name)) {
writeln!(
process().stderr().lock(),
"Opening docs named `{name}` in your browser"
)?;
topic_name = Some(name);
path
} else {
writeln!(process().stderr().lock(), "Opening docs in your browser")?;
"index.html"
};

Expand All @@ -1614,6 +1611,14 @@ fn doc(cfg: &Cfg, m: &ArgMatches) -> Result<utils::ExitCode> {
writeln!(process().stdout().lock(), "{}", doc_path.display())?;
Ok(utils::ExitCode(0))
} else {
if let Some(name) = topic_name {
writeln!(
process().stderr().lock(),
"Opening docs named `{name}` in your browser"
)?;
} else {
writeln!(process().stderr().lock(), "Opening docs in your browser")?;
}
toolchain.open_docs(doc_url)?;
Ok(utils::ExitCode(0))
}
Expand Down

0 comments on commit 7f4372e

Please sign in to comment.