]> git.lizzy.rs Git - rust.git/blobdiff - src/bootstrap/builder.rs
Rollup merge of #103445 - fmease:fix-50291, r=estebank
[rust.git] / src / bootstrap / builder.rs
index e467ce47f4c0d3acb29f2039bb6cf9bd37f6d690..6fd363935079dcd001ba778f96242efcc7550a17 100644 (file)
@@ -2208,6 +2208,24 @@ pub(crate) fn was_invoked_explicitly<S: Step>(&'a self, kind: Kind) -> bool {
 
         false
     }
+
+    pub(crate) fn maybe_open_in_browser<S: Step>(&self, path: impl AsRef<Path>) {
+        if self.was_invoked_explicitly::<S>(Kind::Doc) {
+            self.open_in_browser(path);
+        }
+    }
+
+    pub(crate) fn open_in_browser(&self, path: impl AsRef<Path>) {
+        if self.config.dry_run || !self.config.cmd.open() {
+            return;
+        }
+
+        let path = path.as_ref();
+        self.info(&format!("Opening doc {}", path.display()));
+        if let Err(err) = opener::open(path) {
+            self.info(&format!("{}\n", err));
+        }
+    }
 }
 
 #[cfg(test)]