diff --git a/Cargo.lock b/Cargo.lock index d05aaed..4ea41ee 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -271,6 +271,7 @@ dependencies = [ "eyre", "forgejo-api", "futures", + "open", "serde", "serde_json", "soft_assert", @@ -587,6 +588,15 @@ version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" +[[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-terminal" version = "0.4.9" @@ -598,6 +608,16 @@ dependencies = [ "windows-sys", ] +[[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.8" @@ -728,6 +748,17 @@ version = "1.18.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" +[[package]] +name = "open" +version = "5.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cfabf1927dce4d6fdf563d63328a0a506101ced3ec780ca2135747336c98cef8" +dependencies = [ + "is-wsl", + "libc", + "pathdiff", +] + [[package]] name = "openssl" version = "0.10.55" @@ -801,6 +832,12 @@ dependencies = [ "windows-targets", ] +[[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.0" diff --git a/Cargo.toml b/Cargo.toml index 44ab8bf..c430c0c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,7 @@ directories = "5.0.1" eyre = "0.6.8" forgejo-api = { path = "./forgejo-api" } futures = "0.3.28" +open = "5.0.0" serde = { version = "1.0.170", features = ["derive"] } serde_json = "1.0.100" soft_assert = "0.1.1" diff --git a/src/main.rs b/src/main.rs index a41bdfe..78bca92 100644 --- a/src/main.rs +++ b/src/main.rs @@ -44,6 +44,7 @@ pub enum RepoCommand { push: bool }, Info, + Browse, } #[derive(Subcommand, Clone, Debug)] @@ -149,6 +150,11 @@ async fn main() -> eyre::Result<()> { None => eprintln!("repo not found"), } } + RepoCommand::Browse => { + let (host_domain, host_keys, repo) = keys.get_current_host_and_repo().await?; + let (_, user) = host_keys.get_current_user()?; + open::that(format!("http://{host_domain}/{}/{repo}", user.name))?; + } }, Command::User { host } => { let (host_domain, host_keys) = match host.as_deref() {