fix more lints
This commit is contained in:
@@ -9,7 +9,7 @@ use crate::backend::backend_trait::*;
|
|||||||
use crate::{impl_backend_constants, Group, Package};
|
use crate::{impl_backend_constants, Group, Package};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct Pacman {
|
pub struct Pacman {
|
||||||
pub(crate) binary: String,
|
pub(crate) binary: String,
|
||||||
pub(crate) aur_rm_args: Option<Vec<String>>,
|
pub(crate) aur_rm_args: Option<Vec<String>>,
|
||||||
pub(crate) packages: HashSet<Package>,
|
pub(crate) packages: HashSet<Package>,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use crate::backend::backend_trait::*;
|
|||||||
use crate::{impl_backend_constants, Group, Package};
|
use crate::{impl_backend_constants, Group, Package};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct Rust {
|
pub struct Rust {
|
||||||
pub(crate) packages: HashSet<Package>,
|
pub(crate) packages: HashSet<Package>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use crate::{Group, Package};
|
|||||||
pub(in crate::backend) type Switches = &'static [&'static str];
|
pub(in crate::backend) type Switches = &'static [&'static str];
|
||||||
pub(in crate::backend) type Text = &'static str;
|
pub(in crate::backend) type Text = &'static str;
|
||||||
|
|
||||||
pub(crate) trait Backend: Debug {
|
pub trait Backend: Debug {
|
||||||
fn get_binary(&self) -> Text;
|
fn get_binary(&self) -> Text;
|
||||||
fn get_section(&self) -> Text;
|
fn get_section(&self) -> Text;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
use super::{Backend, Backends};
|
use super::{Backend, Backends};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct BackendIter {
|
pub struct BackendIter {
|
||||||
pub(crate) next: Option<Backends>,
|
pub(crate) next: Option<Backends>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ mod iter;
|
|||||||
mod macros;
|
mod macros;
|
||||||
mod todo_per_backend;
|
mod todo_per_backend;
|
||||||
|
|
||||||
pub(crate) use backend_trait::Backend;
|
pub use backend_trait::Backend;
|
||||||
pub(crate) use iter::BackendIter;
|
pub use iter::BackendIter;
|
||||||
pub(crate) use todo_per_backend::ToDoPerBackend;
|
pub use todo_per_backend::ToDoPerBackend;
|
||||||
|
|
||||||
use ::macros::Register;
|
use ::macros::Register;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use super::Backend;
|
|||||||
use crate::Package;
|
use crate::Package;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub(crate) struct ToDoPerBackend(Vec<(Box<dyn Backend>, Vec<Package>)>);
|
pub struct ToDoPerBackend(Vec<(Box<dyn Backend>, Vec<Package>)>);
|
||||||
|
|
||||||
impl ToDoPerBackend {
|
impl ToDoPerBackend {
|
||||||
pub(crate) fn new() -> Self {
|
pub(crate) fn new() -> Self {
|
||||||
|
|||||||
@@ -307,6 +307,7 @@ fn get_assumed_group_file_names(arg_match: &ArgMatches) -> Result<Vec<PathBuf>>
|
|||||||
Ok(paths)
|
Ok(paths)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::option_if_let_else)]
|
||||||
fn show_error(error: &anyhow::Error, backend: &dyn Backend) {
|
fn show_error(error: &anyhow::Error, backend: &dyn Backend) {
|
||||||
let section = backend.get_section();
|
let section = backend.get_section();
|
||||||
match get_single_var("RUST_BACKTRACE") {
|
match get_single_var("RUST_BACKTRACE") {
|
||||||
@@ -319,7 +320,7 @@ fn show_error(error: &anyhow::Error, backend: &dyn Backend) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) const fn get_version_string() -> &'static str {
|
pub const fn get_version_string() -> &'static str {
|
||||||
concat!(
|
concat!(
|
||||||
"pacdef, version: ",
|
"pacdef, version: ",
|
||||||
env!("CARGO_PKG_VERSION"),
|
env!("CARGO_PKG_VERSION"),
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ use std::env::var;
|
|||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Result};
|
||||||
|
|
||||||
pub(crate) fn get_editor() -> Result<String> {
|
pub fn get_editor() -> Result<String> {
|
||||||
check_vars_in_order(&["EDITOR", "VISUAL"]).ok_or_else(|| anyhow!("could not find editor"))
|
check_vars_in_order(&["EDITOR", "VISUAL"]).ok_or_else(|| anyhow!("could not find editor"))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -10,6 +10,6 @@ fn check_vars_in_order(vars: &[&str]) -> Option<String> {
|
|||||||
vars.iter().find_map(|v| var(v).ok())
|
vars.iter().find_map(|v| var(v).ok())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_single_var(variable: &str) -> Option<String> {
|
pub fn get_single_var(variable: &str) -> Option<String> {
|
||||||
var(variable).ok()
|
var(variable).ok()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,14 +48,16 @@ impl Package {
|
|||||||
|
|
||||||
impl PartialEq for Package {
|
impl PartialEq for Package {
|
||||||
fn eq(&self, other: &Self) -> bool {
|
fn eq(&self, other: &Self) -> bool {
|
||||||
self.name == other.name
|
let self_repo = self.repo.as_ref();
|
||||||
&& match &self.repo {
|
let other_repo = other.repo.as_ref();
|
||||||
None => true,
|
|
||||||
Some(r) => match &other.repo {
|
// iff both packages have repos, they must be identical, otherwise we don't care
|
||||||
None => true,
|
let repos_are_identical =
|
||||||
Some(r2) => r == r2,
|
self_repo.map_or(true, |sr| other_repo.map_or(true, |or| sr == or));
|
||||||
},
|
|
||||||
}
|
let names_are_identical = self.name == other.name;
|
||||||
|
|
||||||
|
names_are_identical && repos_are_identical
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,13 +2,13 @@ use std::{env, path::PathBuf};
|
|||||||
|
|
||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
|
|
||||||
pub(crate) fn get_pacdef_group_dir() -> Result<PathBuf> {
|
pub fn get_pacdef_group_dir() -> Result<PathBuf> {
|
||||||
let mut result = get_pacdef_base_dir().context("getting pacdef base dir")?;
|
let mut result = get_pacdef_base_dir().context("getting pacdef base dir")?;
|
||||||
result.push("groups");
|
result.push("groups");
|
||||||
Ok(result)
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_pacdef_base_dir() -> Result<PathBuf> {
|
pub fn get_pacdef_base_dir() -> Result<PathBuf> {
|
||||||
let mut dir = get_xdg_config_home().context("getting XDG_CONFIG_HOME")?;
|
let mut dir = get_xdg_config_home().context("getting XDG_CONFIG_HOME")?;
|
||||||
dir.push("pacdef");
|
dir.push("pacdef");
|
||||||
Ok(dir)
|
Ok(dir)
|
||||||
@@ -24,6 +24,6 @@ fn get_xdg_config_home() -> Result<PathBuf> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_home_dir() -> Result<PathBuf> {
|
pub fn get_home_dir() -> Result<PathBuf> {
|
||||||
Ok(env::var("HOME").context("getting $HOME variable")?.into())
|
Ok(env::var("HOME").context("getting $HOME variable")?.into())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use crate::grouping::{Group, Package, Section};
|
|||||||
|
|
||||||
pub const NO_PACKAGES_FOUND: &str = "no packages matching query";
|
pub const NO_PACKAGES_FOUND: &str = "no packages matching query";
|
||||||
|
|
||||||
pub(crate) fn search_packages(args: &ArgMatches, groups: &HashSet<Group>) -> Result<()> {
|
pub fn search_packages(args: &ArgMatches, groups: &HashSet<Group>) -> Result<()> {
|
||||||
let search_string = args
|
let search_string = args
|
||||||
.get_one::<String>("string")
|
.get_one::<String>("string")
|
||||||
.context("getting search string from arg")?;
|
.context("getting search string from arg")?;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ use std::io::{self, Read, Write};
|
|||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use termios::*;
|
use termios::*;
|
||||||
|
|
||||||
pub(crate) fn get_user_confirmation() -> Result<bool> {
|
pub fn get_user_confirmation() -> Result<bool> {
|
||||||
print!("Continue? [Y/n] ");
|
print!("Continue? [Y/n] ");
|
||||||
std::io::stdout().flush().context("flushing stdout")?;
|
std::io::stdout().flush().context("flushing stdout")?;
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ pub(crate) fn get_user_confirmation() -> Result<bool> {
|
|||||||
Ok(reply.trim().is_empty() || reply.to_lowercase().contains('y'))
|
Ok(reply.trim().is_empty() || reply.to_lowercase().contains('y'))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn read_single_char_from_terminal() -> Result<char> {
|
pub fn read_single_char_from_terminal() -> Result<char> {
|
||||||
// 0 is the file descriptor for stdin
|
// 0 is the file descriptor for stdin
|
||||||
let fd = 0;
|
let fd = 0;
|
||||||
let termios = Termios::from_fd(fd).context("getting stdin fd")?;
|
let termios = Termios::from_fd(fd).context("getting stdin fd")?;
|
||||||
|
|||||||
Reference in New Issue
Block a user