Skip to content

Commit

Permalink
refactor!(aura): remove open command
Browse files Browse the repository at this point in the history
It was not useful. For docs and guides, we have a man page and the
Guide, and I intend the supply an `info` variant of the Guide as well
for offline usage.

This also enabled the removal of the `webbrowser` dependency.

2,920,400 -> 2,597,712
  • Loading branch information
fosskers committed Jul 17, 2024
1 parent 30aba9f commit ebfa179
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 373 deletions.
260 changes: 0 additions & 260 deletions rust/Cargo.lock

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion rust/aura-pm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion rust/aura-pm/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
16 changes: 13 additions & 3 deletions rust/aura-pm/src/command/aur.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -60,6 +63,7 @@ pub(crate) enum Error {
Cancelled,
Stdout,
ReadDir(PathBuf, std::io::Error),
CouldntOpen(String, std::io::Error),
}

impl Nested for Error {
Expand All @@ -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}"),
}
}
}
Expand All @@ -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),
}
}
}
Expand Down Expand Up @@ -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<ColoredString, Error> {
Expand Down
65 changes: 0 additions & 65 deletions rust/aura-pm/src/command/open.rs

This file was deleted.

9 changes: 0 additions & 9 deletions rust/aura-pm/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand All @@ -28,12 +27,6 @@ impl From<crate::deps::Error> for Error {
}
}

impl From<crate::open::Error> for Error {
fn from(v: crate::open::Error) -> Self {
Self::Open(v)
}
}

impl From<crate::stats::Error> for Error {
fn from(v: crate::stats::Error) -> Self {
Self::Stats(v)
Expand Down Expand Up @@ -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(),
}
Expand All @@ -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),
}
Expand Down
26 changes: 0 additions & 26 deletions rust/aura-pm/src/flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -1358,30 +1356,6 @@ pub struct Cache {
pub packages: Vec<String>,
}

/// 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 {
Expand Down
8 changes: 0 additions & 8 deletions rust/aura-pm/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)?
Expand Down

0 comments on commit ebfa179

Please sign in to comment.