clean up minor items

This commit is contained in:
steven-omaha
2023-01-10 15:00:21 +01:00
parent 160e4d0b4c
commit 627f66ea35
6 changed files with 6 additions and 33 deletions
-11
View File
@@ -23,17 +23,6 @@ impl Backends {
pub fn iter() -> BackendIter {
BackendIter(Some(Self::Pacman))
}
fn get(&self) -> Box<dyn Backend> {
match self {
Self::Pacman => Box::new(Pacman {
packages: HashSet::new(),
}),
Self::Rust => Box::new(Rust {
packages: HashSet::new(),
}),
}
}
}
#[derive(Debug)]
+2 -2
View File
@@ -1,12 +1,12 @@
use std::path::PathBuf;
use std::process::{Command, ExitStatus};
use anyhow::{anyhow, Result};
use anyhow::{anyhow, Context, Result};
use crate::env::get_editor;
pub fn run_edit_command(files: &[PathBuf]) -> Result<ExitStatus> {
let mut cmd = Command::new(get_editor()?);
let mut cmd = Command::new(get_editor().context("getting suitable editor")?);
cmd.current_dir(files[0].parent().unwrap());
for f in files {
cmd.arg(f.to_string_lossy().to_string());
+2 -2
View File
@@ -9,8 +9,8 @@ use crate::section::Section;
#[derive(Debug)]
pub struct Group {
pub name: String,
pub sections: HashSet<Section>,
pub(crate) name: String,
pub(crate) sections: HashSet<Section>,
}
impl Group {
+1 -1
View File
@@ -1,6 +1,6 @@
mod action;
pub mod args;
pub mod backend;
mod backend;
mod cmd;
mod core;
mod env;
+1 -11
View File
@@ -1,10 +1,9 @@
use std::collections::HashSet;
use std::fmt::{Display, Write};
use std::hash::Hash;
#[derive(Debug, Eq, PartialOrd, Ord, Clone)]
pub struct Package {
pub name: String,
pub(crate) name: String,
repo: Option<String>,
}
@@ -16,15 +15,6 @@ fn remove_all_but_package_name(s: &str) -> &str {
}
impl Package {
pub(crate) fn from_lines(
lines: impl Iterator<Item = Result<String, std::io::Error>>,
) -> HashSet<Self> {
lines
.into_iter()
.filter_map(|l| Package::try_from(l.unwrap()))
.collect()
}
fn split_into_name_and_repo(s: &str) -> (String, Option<String>) {
let mut iter = s.split('/').rev();
let name = iter.next().unwrap().to_string();
-6
View File
@@ -8,12 +8,6 @@ pub(crate) fn get_pacdef_group_dir() -> Result<PathBuf> {
Ok(result)
}
pub(crate) fn get_pacdef_config_file() -> Result<PathBuf> {
let mut result = get_pacdef_base_dir().context("getting pacdef base dir")?;
result.push("pacdef.conf");
Ok(result)
}
fn get_pacdef_base_dir() -> Result<PathBuf> {
let mut dir = get_xdg_config_home().context("getting XDG_CONFIG_HOME")?;
dir.push("pacdef");