Skip to content

Commit

Permalink
feat: allow opening the browser with --open
Browse files Browse the repository at this point in the history
  • Loading branch information
ctron committed May 17, 2024
1 parent d21b2ee commit 73c9a2d
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
37 changes: 37 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 Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ directories = "5"
humantime = "2"
log = "0.4"
num-traits = "0.2"
open = "5"
openid = "0.14"
reqwest = "0.12"
serde = { version = "1", features = ["derive"] }
Expand Down
12 changes: 11 additions & 1 deletion src/cmd/create/public.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ pub struct CreatePublic {
/// Force using a specific port for the local server
#[arg(short, long)]
pub port: Option<u16>,

/// Open the link automatically
#[arg(short, long)]
pub open: bool,
}

impl CreatePublic {
Expand Down Expand Up @@ -61,13 +65,19 @@ impl CreatePublic {
println!(
r#"
Open the following URL in your browser and perform the interactive login process:
Open the following URL in your browser and perform the interactive login process (use --open to do this automatically):
{open}
"#
);

if let Err(err) = open::that(open.to_string()) {
log::warn!(
"Failed to open URL in browser. You can still copy the link from the console. Error: {err}"
);
}

let result = server.receive_token().await?;
let token = client.request_token(&result.code).await?;

Expand Down

0 comments on commit 73c9a2d

Please sign in to comment.