amodm / webbrowser-rs

Rust library to open URLs in the web browsers available on a platform

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Output of external commands gets printed to stdout

SitiSchu opened this issue · comments

In my case on Linux the call to xdg-open causes Opening in existing browser session to be printed to the console. Would it make sense to silence all output of the external tools by default unless there's an error?

Makes sense. Probably better with a flag (defaulted to false) that can be enabled to switch on the output.

Workaround:

Add to your Cargo.toml

[dependencies]
webbrowser = { git = "https://github.com/codota/webbrowser-rs", branch = "feature/add-suppress-output-flag-with-docs" }

In your code:

use webbrowser::{self, BrowserOptions};

    if webbrowser::open_browser_with_options(
      BrowserOptions {
        url: String::from(token_url),
        suppress_output: Some(true),
        browser: Some(webbrowser::Browser::Default),
      }).is_ok() {}

Ultimately should merge #22 though

Hello! I am having the same issue here, bump ? :)

I can take care of it if no one is doing it

Fixed in ecfbf66. By default, we now suppress output for all GUI browsers. This behaviour can be overridden. See Consistent Behaviour section for details.