clean up minor items
This commit is contained in:
@@ -23,17 +23,6 @@ impl Backends {
|
|||||||
pub fn iter() -> BackendIter {
|
pub fn iter() -> BackendIter {
|
||||||
BackendIter(Some(Self::Pacman))
|
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)]
|
#[derive(Debug)]
|
||||||
|
|||||||
+2
-2
@@ -1,12 +1,12 @@
|
|||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
use std::process::{Command, ExitStatus};
|
use std::process::{Command, ExitStatus};
|
||||||
|
|
||||||
use anyhow::{anyhow, Result};
|
use anyhow::{anyhow, Context, Result};
|
||||||
|
|
||||||
use crate::env::get_editor;
|
use crate::env::get_editor;
|
||||||
|
|
||||||
pub fn run_edit_command(files: &[PathBuf]) -> Result<ExitStatus> {
|
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());
|
cmd.current_dir(files[0].parent().unwrap());
|
||||||
for f in files {
|
for f in files {
|
||||||
cmd.arg(f.to_string_lossy().to_string());
|
cmd.arg(f.to_string_lossy().to_string());
|
||||||
|
|||||||
+2
-2
@@ -9,8 +9,8 @@ use crate::section::Section;
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Group {
|
pub struct Group {
|
||||||
pub name: String,
|
pub(crate) name: String,
|
||||||
pub sections: HashSet<Section>,
|
pub(crate) sections: HashSet<Section>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Group {
|
impl Group {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
mod action;
|
mod action;
|
||||||
pub mod args;
|
pub mod args;
|
||||||
pub mod backend;
|
mod backend;
|
||||||
mod cmd;
|
mod cmd;
|
||||||
mod core;
|
mod core;
|
||||||
mod env;
|
mod env;
|
||||||
|
|||||||
+1
-11
@@ -1,10 +1,9 @@
|
|||||||
use std::collections::HashSet;
|
|
||||||
use std::fmt::{Display, Write};
|
use std::fmt::{Display, Write};
|
||||||
use std::hash::Hash;
|
use std::hash::Hash;
|
||||||
|
|
||||||
#[derive(Debug, Eq, PartialOrd, Ord, Clone)]
|
#[derive(Debug, Eq, PartialOrd, Ord, Clone)]
|
||||||
pub struct Package {
|
pub struct Package {
|
||||||
pub name: String,
|
pub(crate) name: String,
|
||||||
repo: Option<String>,
|
repo: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -16,15 +15,6 @@ fn remove_all_but_package_name(s: &str) -> &str {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Package {
|
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>) {
|
fn split_into_name_and_repo(s: &str) -> (String, Option<String>) {
|
||||||
let mut iter = s.split('/').rev();
|
let mut iter = s.split('/').rev();
|
||||||
let name = iter.next().unwrap().to_string();
|
let name = iter.next().unwrap().to_string();
|
||||||
|
|||||||
@@ -8,12 +8,6 @@ pub(crate) fn get_pacdef_group_dir() -> Result<PathBuf> {
|
|||||||
Ok(result)
|
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> {
|
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");
|
||||||
|
|||||||
Reference in New Issue
Block a user