diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 9de32145c..c59839e49 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -149,7 +149,6 @@ dependencies = [ "ubyte", "unic-langid", "validated", - "webbrowser", "which", "whoami", ] @@ -181,39 +180,18 @@ dependencies = [ "generic-array", ] -[[package]] -name = "block2" -version = "0.5.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c132eebf10f5cad5289222520a4a058514204aed6d791f1cf4fe8088b82d15f" -dependencies = [ - "objc2", -] - [[package]] name = "bumpalo" version = "3.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" -[[package]] -name = "bytes" -version = "1.6.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" - [[package]] name = "cc" version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "324c74f2155653c90b04f25b2a47a8a631360cb908f92a772695f430c7e31052" -[[package]] -name = "cesu8" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d43a04d8753f35258c91f8ec639f792891f748a1edbd759cf1dcea3382ad83c" - [[package]] name = "cfg-if" version = "1.0.0" @@ -297,32 +275,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "combine" -version = "4.6.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba5a308b75df32fe02788e748662718f03fde005016435c444eea572398219fd" -dependencies = [ - "bytes", - "memchr", -] - -[[package]] -name = "core-foundation" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" -dependencies = [ - "core-foundation-sys", - "libc", -] - -[[package]] -name = "core-foundation-sys" -version = "0.8.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" - [[package]] name = "cpufeatures" version = "0.2.12" @@ -551,15 +503,6 @@ dependencies = [ "thiserror", ] -[[package]] -name = "form_urlencoded" -version = "1.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" -dependencies = [ - "percent-encoding", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -666,16 +609,6 @@ dependencies = [ "syn 2.0.71", ] -[[package]] -name = "idna" -version = "0.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6" -dependencies = [ - "unicode-bidi", - "unicode-normalization", -] - [[package]] name = "indexmap" version = "2.2.6" @@ -726,28 +659,6 @@ version = "1.0.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "49f1f14873335454500d59611f1cf4a4b0f786f9ac11f4312a78e4cf2566695b" -[[package]] -name = "jni" -version = "0.21.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a87aa2bb7d2af34197c04845522473242e1aa17c12f4935d5856491a7fb8c97" -dependencies = [ - "cesu8", - "cfg-if", - "combine", - "jni-sys", - "log", - "thiserror", - "walkdir", - "windows-sys 0.45.0", -] - -[[package]] -name = "jni-sys" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" - [[package]] name = "js-sys" version = "0.3.69" @@ -834,12 +745,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "ndk-context" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b02d87554356db9e9a873add8782d4ea6e3e58ea071a9adb9a2e8ddb884a8b" - [[package]] name = "nibble_vec" version = "0.1.0" @@ -902,40 +807,6 @@ dependencies = [ "libc", ] -[[package]] -name = "objc-sys" -version = "0.3.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb91bdd390c7ce1a8607f35f3ca7151b65afc0ff5ff3b34fa350f7d7c7e4310" - -[[package]] -name = "objc2" -version = "0.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "46a785d4eeff09c14c487497c162e92766fbb3e4059a71840cecc03d9a50b804" -dependencies = [ - "objc-sys", - "objc2-encode", -] - -[[package]] -name = "objc2-encode" -version = "4.0.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7891e71393cd1f227313c9379a26a584ff3d7e6e7159e988851f0934c993f0f8" - -[[package]] -name = "objc2-foundation" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee638a5da3799329310ad4cfa62fbf045d5f56e3ef5ba4149e7452dcf89d5a8" -dependencies = [ - "bitflags 2.6.0", - "block2", - "libc", - "objc2", -] - [[package]] name = "once_cell" version = "1.19.0" @@ -992,12 +863,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "percent-encoding" -version = "2.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" - [[package]] name = "petgraph" version = "0.6.5" @@ -1465,21 +1330,6 @@ dependencies = [ "displaydoc", ] -[[package]] -name = "tinyvec" -version = "1.8.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" -dependencies = [ - "tinyvec_macros", -] - -[[package]] -name = "tinyvec_macros" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" - [[package]] name = "toml" version = "0.5.11" @@ -1588,27 +1438,12 @@ dependencies = [ "unic-langid-impl", ] -[[package]] -name = "unicode-bidi" -version = "0.3.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" - [[package]] name = "unicode-ident" version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" -[[package]] -name = "unicode-normalization" -version = "0.1.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5" -dependencies = [ - "tinyvec", -] - [[package]] name = "unicode-segmentation" version = "1.11.0" @@ -1621,17 +1456,6 @@ version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" -[[package]] -name = "url" -version = "2.5.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" -dependencies = [ - "form_urlencoded", - "idna", - "percent-encoding", -] - [[package]] name = "utf8parse" version = "0.2.2" @@ -1750,24 +1574,6 @@ dependencies = [ "wasm-bindgen", ] -[[package]] -name = "webbrowser" -version = "1.0.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "425ba64c1e13b1c6e8c5d2541c8fac10022ca584f33da781db01b5756aef1f4e" -dependencies = [ - "block2", - "core-foundation", - "home", - "jni", - "log", - "ndk-context", - "objc2", - "objc2-foundation", - "url", - "web-sys", -] - [[package]] name = "which" version = "6.0.1" @@ -1822,15 +1628,6 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" -[[package]] -name = "windows-sys" -version = "0.45.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" -dependencies = [ - "windows-targets 0.42.2", -] - [[package]] name = "windows-sys" version = "0.48.0" @@ -1849,21 +1646,6 @@ dependencies = [ "windows-targets 0.52.6", ] -[[package]] -name = "windows-targets" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - [[package]] name = "windows-targets" version = "0.48.5" @@ -1895,12 +1677,6 @@ dependencies = [ "windows_x86_64_msvc 0.52.6", ] -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" - [[package]] name = "windows_aarch64_gnullvm" version = "0.48.5" @@ -1913,12 +1689,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" -[[package]] -name = "windows_aarch64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" - [[package]] name = "windows_aarch64_msvc" version = "0.48.5" @@ -1931,12 +1701,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" -[[package]] -name = "windows_i686_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" - [[package]] name = "windows_i686_gnu" version = "0.48.5" @@ -1955,12 +1719,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" -[[package]] -name = "windows_i686_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" - [[package]] name = "windows_i686_msvc" version = "0.48.5" @@ -1973,12 +1731,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" -[[package]] -name = "windows_x86_64_gnu" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" - [[package]] name = "windows_x86_64_gnu" version = "0.48.5" @@ -1991,12 +1743,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" - [[package]] name = "windows_x86_64_gnullvm" version = "0.48.5" @@ -2009,12 +1755,6 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" -[[package]] -name = "windows_x86_64_msvc" -version = "0.42.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" - [[package]] name = "windows_x86_64_msvc" version = "0.48.5" diff --git a/rust/aura-pm/Cargo.toml b/rust/aura-pm/Cargo.toml index 7a7fea6ca..56ac85979 100644 --- a/rust/aura-pm/Cargo.toml +++ b/rust/aura-pm/Cargo.toml @@ -44,7 +44,6 @@ toml = "0.8" ubyte = "0.10" unic-langid = { version = "0.9", features = ["macros", "serde"] } validated = { version = "0.4", features = ["rayon"] } -webbrowser = "1.0" which = "6.0" whoami = "1.5" diff --git a/rust/aura-pm/src/command.rs b/rust/aura-pm/src/command.rs index 7ba6008db..23fcbcfd8 100644 --- a/rust/aura-pm/src/command.rs +++ b/rust/aura-pm/src/command.rs @@ -8,7 +8,6 @@ pub(crate) mod deps; pub(crate) mod free; pub(crate) mod logs; pub(crate) mod misc; -pub(crate) mod open; pub(crate) mod orphans; pub(crate) mod snapshot; pub(crate) mod stats; diff --git a/rust/aura-pm/src/command/aur.rs b/rust/aura-pm/src/command/aur.rs index 743bf5b79..152586ff7 100644 --- a/rust/aura-pm/src/command/aur.rs +++ b/rust/aura-pm/src/command/aur.rs @@ -38,10 +38,13 @@ use std::io::Write; use std::ops::Not; use std::path::Path; use std::path::PathBuf; +use std::process::Command; use std::sync::Mutex; use time::OffsetDateTime; use validated::Validated; +const AUR_PKG_URL: &str = "https://aur.archlinux.org/packages/"; + pub(crate) enum Error { Backup(crate::command::snapshot::Error), Fetch(crate::fetch::Error), @@ -60,6 +63,7 @@ pub(crate) enum Error { Cancelled, Stdout, ReadDir(PathBuf, std::io::Error), + CouldntOpen(String, std::io::Error), } impl Nested for Error { @@ -82,6 +86,7 @@ impl Nested for Error { Error::DateConv(e) => error!("{e}"), Error::Backup(e) => e.nested(), Error::ReadDir(_, e) => error!("{e}"), + Error::CouldntOpen(_, e) => error!("{e}"), } } } @@ -106,6 +111,7 @@ impl Localised for Error { Error::DateConv(_) => fl!(fll, "err-time-conv"), Error::Backup(e) => e.localise(fll), Error::ReadDir(p, _) => fl!(fll, "err-read-dir", dir = p.utf8()), + Error::CouldntOpen(url, _) => fl!(fll, "open-err", url = url), } } } @@ -321,14 +327,18 @@ pub(crate) fn pkgbuild(pkg: &str, clone_d: &Path) -> Result<(), Error> { } /// Open a given package's AUR package in a browser. -pub(crate) fn open(package: &str) -> Result<(), crate::open::Error> { +pub(crate) fn open(package: &str) -> Result<(), Error> { let url = package_url(package); - crate::open::open(&url) + Command::new("xdg-open") + .arg(&url) + .status() + .map_err(|e| Error::CouldntOpen(url, e))?; + Ok(()) } /// A package's URL on the AUR. fn package_url(package: &str) -> String { - format!("{}{}", crate::open::AUR_PKG_URL, package) + format!("{}{}", AUR_PKG_URL, package) } fn package_date(epoch: u64) -> Result { diff --git a/rust/aura-pm/src/command/open.rs b/rust/aura-pm/src/command/open.rs deleted file mode 100644 index 91c4e5ad8..000000000 --- a/rust/aura-pm/src/command/open.rs +++ /dev/null @@ -1,65 +0,0 @@ -//! Open various webpages related to Aura. - -use crate::error::Nested; -use crate::localization::Localised; -use i18n_embed_fl::fl; -use log::error; -use std::borrow::Cow; - -const BOOK_URL: &str = "https://fosskers.github.io/aura/"; -const REPO_URL: &str = "https://github.com/fosskers/aura"; -const ISSUE_URL: &str = "https://github.com/fosskers/aura/issues/new"; -const LIC_URL: &str = "https://github.com/fosskers/aura/blob/master/aura/LICENSE"; -pub const AUR_PKG_URL: &str = "https://aur.archlinux.org/packages/"; - -pub(crate) enum Error { - CouldntOpen(String, std::io::Error), -} - -impl Nested for Error { - fn nested(&self) { - match self { - Error::CouldntOpen(_, e) => error!("{e}"), - } - } -} - -impl Localised for Error { - fn localise(&self, fll: &i18n_embed::fluent::FluentLanguageLoader) -> String { - match self { - Error::CouldntOpen(url, _) => fl!(fll, "open-err", url = url.as_str()), - } - } -} - -/// Open the Aura Book. -pub(crate) fn book() -> Result<(), Error> { - open(BOOK_URL) -} - -/// Open Aura's Github repository. -pub(crate) fn repo() -> Result<(), Error> { - open(REPO_URL) -} - -/// File a bug report for Aura. -pub(crate) fn bug() -> Result<(), Error> { - open(ISSUE_URL) -} - -/// Open Aura's AUR page. -pub(crate) fn aur() -> Result<(), Error> { - let mut url = Cow::from(AUR_PKG_URL); - url += "aura"; - open(&url) -} - -/// Open Aura's LICENSE file. -pub(crate) fn license() -> Result<(), Error> { - open(LIC_URL) -} - -/// Open a given URL in a browser. -pub(crate) fn open(url: &str) -> Result<(), Error> { - webbrowser::open(url).map_err(|e| Error::CouldntOpen(url.to_string(), e)) -} diff --git a/rust/aura-pm/src/error.rs b/rust/aura-pm/src/error.rs index 730b93333..5b0ecdedf 100644 --- a/rust/aura-pm/src/error.rs +++ b/rust/aura-pm/src/error.rs @@ -17,7 +17,6 @@ pub(crate) enum Error { Env(crate::env::Error), Conf(crate::conf::Error), Check(crate::check::Error), - Open(crate::open::Error), Stats(crate::stats::Error), Deps(crate::deps::Error), } @@ -28,12 +27,6 @@ impl From for Error { } } -impl From for Error { - fn from(v: crate::open::Error) -> Self { - Self::Open(v) - } -} - impl From for Error { fn from(v: crate::stats::Error) -> Self { Self::Stats(v) @@ -101,7 +94,6 @@ impl Nested for Error { Error::Env(e) => e.nested(), Error::Conf(e) => e.nested(), Error::Check(e) => e.nested(), - Error::Open(e) => e.nested(), Error::Stats(e) => e.nested(), Error::Deps(e) => e.nested(), } @@ -120,7 +112,6 @@ impl Localised for Error { Error::Env(e) => e.localise(fll), Error::Conf(e) => e.localise(fll), Error::Check(e) => e.localise(fll), - Error::Open(e) => e.localise(fll), Error::Stats(e) => e.localise(fll), Error::Deps(e) => e.localise(fll), } diff --git a/rust/aura-pm/src/flags.rs b/rust/aura-pm/src/flags.rs index 135ee5649..d92c006f2 100644 --- a/rust/aura-pm/src/flags.rs +++ b/rust/aura-pm/src/flags.rs @@ -406,8 +406,6 @@ pub enum SubCmd { Conf(Conf), /// Output a dependency graph in DOT format. Deps(Deps), - /// Open various webpages related to Aura. - Open(Open), /// View statistics about your machine or about Aura itself. Stats(Stats), /// The people behind Aura. @@ -1358,30 +1356,6 @@ pub struct Cache { pub packages: Vec, } -/// Open various webpages related to Aura. -#[derive(Parser, Debug)] -pub struct Open { - /// Open the Aura Guide Book. - #[clap(group = "open", long, short, display_order = 1)] - pub docs: bool, - - /// Open Aura's Github repository. - #[clap(group = "open", long, short, display_order = 1)] - pub repo: bool, - - /// File a bug report for Aura. - #[clap(group = "open", long, short, display_order = 1)] - pub bug: bool, - - /// Open Aura's LICENSE file. - #[clap(group = "open", long, short, display_order = 1)] - pub license: bool, - - /// Open Aura's AUR page. - #[clap(group = "open", long, short, display_order = 1)] - pub aur: bool, -} - /// Output a dependency graph PNG. #[derive(Parser, Debug)] pub struct Deps { diff --git a/rust/aura-pm/src/main.rs b/rust/aura-pm/src/main.rs index 2148b8103..9721f5f48 100644 --- a/rust/aura-pm/src/main.rs +++ b/rust/aura-pm/src/main.rs @@ -48,7 +48,6 @@ use crate::command::check; use crate::command::conf; use crate::command::deps; use crate::command::logs; -use crate::command::open; use crate::command::orphans; use crate::command::snapshot; use crate::command::stats; @@ -218,13 +217,6 @@ fn work(args: Args, env: Env, fll: &FluentLanguageLoader) -> Result<(), Error> { SubCmd::Stats(s) if s.heavy => stats::heavy_packages(&env.alpm()?), SubCmd::Stats(s) if s.groups => stats::groups(&env.alpm()?), SubCmd::Stats(_) => stats::stats(&env, fll)?, - // --- Opening Webpages --- // - SubCmd::Open(o) if o.docs => open::book()?, - SubCmd::Open(o) if o.repo => open::repo()?, - SubCmd::Open(o) if o.bug => open::bug()?, - SubCmd::Open(o) if o.aur => open::aur()?, - SubCmd::Open(o) if o.license => open::license()?, - SubCmd::Open(_) => open::repo()?, // --- Dependency Management --- // SubCmd::Deps(d) if d.reverse => { deps::reverse(&env.alpm()?, d.limit, d.optional, d.raw, d.open, d.packages)?