add repo browse

This commit is contained in:
Cyborus04 2023-07-11 13:05:00 -04:00
parent 22aad204d3
commit d3fe4091a3
No known key found for this signature in database
3 changed files with 44 additions and 0 deletions

37
Cargo.lock generated
View file

@ -271,6 +271,7 @@ dependencies = [
"eyre", "eyre",
"forgejo-api", "forgejo-api",
"futures", "futures",
"open",
"serde", "serde",
"serde_json", "serde_json",
"soft_assert", "soft_assert",
@ -587,6 +588,15 @@ version = "2.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28b29a3cd74f0f4598934efe3aeba42bae0eb4680554128851ebbecb02af14e6" 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]] [[package]]
name = "is-terminal" name = "is-terminal"
version = "0.4.9" version = "0.4.9"
@ -598,6 +608,16 @@ dependencies = [
"windows-sys", "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]] [[package]]
name = "itoa" name = "itoa"
version = "1.0.8" version = "1.0.8"
@ -728,6 +748,17 @@ version = "1.18.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" 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]] [[package]]
name = "openssl" name = "openssl"
version = "0.10.55" version = "0.10.55"
@ -801,6 +832,12 @@ dependencies = [
"windows-targets", "windows-targets",
] ]
[[package]]
name = "pathdiff"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd"
[[package]] [[package]]
name = "percent-encoding" name = "percent-encoding"
version = "2.3.0" version = "2.3.0"

View file

@ -11,6 +11,7 @@ directories = "5.0.1"
eyre = "0.6.8" eyre = "0.6.8"
forgejo-api = { path = "./forgejo-api" } forgejo-api = { path = "./forgejo-api" }
futures = "0.3.28" futures = "0.3.28"
open = "5.0.0"
serde = { version = "1.0.170", features = ["derive"] } serde = { version = "1.0.170", features = ["derive"] }
serde_json = "1.0.100" serde_json = "1.0.100"
soft_assert = "0.1.1" soft_assert = "0.1.1"

View file

@ -44,6 +44,7 @@ pub enum RepoCommand {
push: bool push: bool
}, },
Info, Info,
Browse,
} }
#[derive(Subcommand, Clone, Debug)] #[derive(Subcommand, Clone, Debug)]
@ -149,6 +150,11 @@ async fn main() -> eyre::Result<()> {
None => eprintln!("repo not found"), 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 } => { Command::User { host } => {
let (host_domain, host_keys) = match host.as_deref() { let (host_domain, host_keys) = match host.as_deref() {