diff options
author | Cyborus04 <87248184+Cyborus04@users.noreply.github.com> | 2023-07-11 19:05:00 +0200 |
---|---|---|
committer | Cyborus04 <87248184+Cyborus04@users.noreply.github.com> | 2023-07-11 19:05:00 +0200 |
commit | d3fe4091a3a2459c64d707224b18cac38c7cf3d8 (patch) | |
tree | 2330cf95ea57b739f263480998766ce03e01b6fb | |
parent | fix push flag (diff) | |
download | forgejo-api-d3fe4091a3a2459c64d707224b18cac38c7cf3d8.tar.xz forgejo-api-d3fe4091a3a2459c64d707224b18cac38c7cf3d8.zip |
add `repo browse`
-rw-r--r-- | Cargo.lock | 37 | ||||
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/main.rs | 6 |
3 files changed, 44 insertions, 0 deletions
@@ -271,6 +271,7 @@ dependencies = [ "eyre", "forgejo-api", "futures", + "open", "serde", "serde_json", "soft_assert", @@ -588,6 +589,15 @@ 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" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -599,6 +609,16 @@ dependencies = [ ] [[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" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -729,6 +749,17 @@ 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" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -802,6 +833,12 @@ dependencies = [ ] [[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" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -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() { |