diff --git a/Cargo.lock b/Cargo.lock index fe509e2..76a751d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -247,6 +247,7 @@ dependencies = [ "colored", "home", "inquire", + "open", "reqwest", "serde_json", "tokio", @@ -412,6 +413,25 @@ version = "2.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +[[package]] +name = "is-docker" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "928bae27f42bc99b60d9ac7334e3a21d10ad8f1835a4e12ec3ec0464765ed1b3" +dependencies = [ + "once_cell", +] + +[[package]] +name = "is-wsl" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "173609498df190136aa7dea1a91db051746d339e18476eed5ca40521f02d7aa5" +dependencies = [ + "is-docker", + "once_cell", +] + [[package]] name = "itoa" version = "1.0.10" @@ -546,6 +566,17 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "open" +version = "5.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "449f0ff855d85ddbf1edd5b646d65249ead3f5e422aaa86b7d2d0b049b103e32" +dependencies = [ + "is-wsl", + "libc", + "pathdiff", +] + [[package]] name = "openssl" version = "0.10.62" @@ -613,6 +644,12 @@ dependencies = [ "windows-targets 0.48.5", ] +[[package]] +name = "pathdiff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" + [[package]] name = "percent-encoding" version = "2.3.1" diff --git a/Cargo.toml b/Cargo.toml index acb754c..238a508 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,6 +7,7 @@ edition = "2021" colored = "2" home = "0.5.9" inquire = { version = "0.6.2", features = ["editor"] } +open = "5.1.2" reqwest = { version = "0.11", features = ["json"] } serde_json = "1.0" tokio = { version = "1", features = ["full"] } diff --git a/src/main.rs b/src/main.rs index bbaad15..9e36bd3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -53,6 +53,7 @@ async fn pr_command() -> Result<(), Box> { let gh = Github::new(&github_token); let pr_url = gh.create_pr(config).await?; + let pr_url = pr_url.replace('"', ""); println!("{}", "✔ Pull request created.".green()); let username = gh.get_username().await?; @@ -63,9 +64,11 @@ async fn pr_command() -> Result<(), Box> { println!( "🎉 Success! The pull request url is: {}", - pr_url.replace('"', "").bright_cyan() + pr_url.bright_cyan() ); + open::that(pr_url)?; + Ok(()) } @@ -123,14 +126,14 @@ fn help_command() { println!(" ghl [command]"); println!(); println!("{}", "Commands".bold()); - println!(" help Display this message."); println!(" config Set the GitHub token and the default pull request description."); - println!(" create, -c Do the following:"); + println!(" help Display this message."); + println!(" pr Do the following:"); println!(" 1. Create a new branch."); println!(" 2. Create a new commit."); println!(" 3. Push to the remote repository."); println!(" 4. Create a new pull request."); println!(" 5. Assign you the pull request."); - println!(" version, -v Display the current and the latest version."); println!(" update, -up Update the binary to the latest version."); + println!(" version, -v Display the current and the latest version."); }