Skip to content

Commit

Permalink
feat!: make open browser fallible (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
futursolo authored Dec 31, 2022
1 parent 9af251a commit d790b76
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 13 deletions.
101 changes: 101 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/stackable-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ reqwest = { version = "0.11.13", features = ["rustls-tls-webpki-roots"] }
# Stackable Components
stackable-core = { version = "0.1.0", path = "../stackable-core" }
tokio-stream = { version = "0.1.11", features = ["sync"] }
webbrowser = "0.8.3"
17 changes: 4 additions & 13 deletions crates/stackable-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,19 +462,10 @@ impl Stackctl {
}

async fn open_browser(&self, http_listen_addr: &str) -> Result<()> {
use tokio::process::Command;
let workspace_dir = self.workspace_dir().await?;

Command::new("open")
.arg(http_listen_addr)
.current_dir(&workspace_dir)
.stdin(Stdio::null())
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn()?
.wait()
.await
.context("failed to open url")?;
if let Err(e) = webbrowser::open(http_listen_addr) {
tracing::warn!("stackctl was unable to open the browser");
tracing::debug!("due to: {:?}", e);
}

Ok(())
}
Expand Down

0 comments on commit d790b76

Please sign in to comment.