Skip to content

Commit

Permalink
refactor: improve coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed May 27, 2020
1 parent a0d33a5 commit 1deb586
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 20 deletions.
16 changes: 8 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 16 additions & 12 deletions src/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@ use structopt::StructOpt;

/// The command line options to be collected.
#[derive(Debug, StructOpt)]
#[structopt(
name = "pacpat-ng",
about = "A pacman-like wrapper for many package managers."
)]
#[structopt(about = "A pacman-like wrapper for many package managers.")]
pub struct Opt {
// Operations include Q(uery), R(emove), and S(ync).
#[structopt(short = "Q", long)]
Expand Down Expand Up @@ -133,8 +130,9 @@ impl Opt {
let no_confirm = self.no_confirm;
let force_cask = self.force_cask;

let unknown = Box::new(unknown::Unknown {});
let unknown = || Box::new(unknown::Unknown {});

// Windows
if cfg!(target_os = "windows") {
// Chocolatey
if is_exe("choco", "") {
Expand All @@ -143,9 +141,11 @@ impl Opt {
no_confirm,
})
} else {
unknown
unknown()
}
} else if cfg!(target_os = "macos") {
}
// macOS
else if cfg!(target_os = "macos") {
// Homebrew
if is_exe("brew", "/usr/local/bin/brew") {
Box::new(homebrew::Homebrew {
Expand All @@ -155,9 +155,11 @@ impl Opt {
no_confirm,
})
} else {
unknown
unknown()
}
} else if cfg!(target_os = "linux") {
}
// Linux
else if cfg!(target_os = "linux") {
// Apt/Dpkg for Debian/Ubuntu/Termux
if is_exe("apt-get", "/usr/bin/apt-get") {
Box::new(dpkg::Dpkg {
Expand All @@ -172,10 +174,12 @@ impl Opt {
no_confirm,
})
} else {
unknown
unknown()
}
} else {
unknown
}
// Unknown OS
else {
unknown()
}
}

Expand Down

0 comments on commit 1deb586

Please sign in to comment.