This commit is contained in:
steven-omaha
2022-12-02 17:08:17 +01:00
parent da70112231
commit 9f068e5ffe
5 changed files with 16 additions and 14 deletions
+5
View File
@@ -0,0 +1,5 @@
pub const EDIT: &str = "edit";
pub const GROUPS: &str = "groups";
pub const SYNC: &str = "sync";
pub const UNMANAGED: &str = "unmanaged";
pub const VERSION: &str = "version";
+2 -6
View File
@@ -1,10 +1,6 @@
use clap::{Arg, Command}; use clap::{Arg, Command};
pub const EDIT: &str = "edit"; use crate::action::*;
pub const GROUPS: &str = "groups";
pub const SYNC: &str = "sync";
pub const UNMANAGED: &str = "unmanaged";
pub const VERSION: &str = "version";
fn get_arg_parser() -> Command<'static> { fn get_arg_parser() -> Command<'static> {
let result = Command::new("pacdef") let result = Command::new("pacdef")
@@ -28,6 +24,6 @@ fn get_arg_parser() -> Command<'static> {
result result
} }
pub fn get_matched_arguments() -> clap::ArgMatches { pub fn get_args() -> clap::ArgMatches {
get_arg_parser().get_matches() get_arg_parser().get_matches()
} }
+6 -6
View File
@@ -2,7 +2,7 @@ use std::collections::HashSet;
use std::path::PathBuf; use std::path::PathBuf;
use std::process::exit; use std::process::exit;
use crate::args; use crate::action;
use crate::cmd::run_install_command; use crate::cmd::run_install_command;
use crate::db::{get_all_installed_packages, get_explicitly_installed_packages}; use crate::db::{get_all_installed_packages, get_explicitly_installed_packages};
use crate::group::{Group, GROUPS_DIR}; use crate::group::{Group, GROUPS_DIR};
@@ -64,11 +64,11 @@ impl Pacdef {
pub fn run_action_from_arg(self) { pub fn run_action_from_arg(self) {
match self.args.subcommand() { match self.args.subcommand() {
// Some((args::EDIT, groups)) => println!("{groups:#?}"), // Some((args::EDIT, groups)) => println!("{groups:#?}"),
Some((args::EDIT, groups)) => self.edit_group_files(groups), Some((action::EDIT, groups)) => self.edit_group_files(groups),
Some((args::GROUPS, _)) => self.show_groups(), Some((action::GROUPS, _)) => self.show_groups(),
Some((args::SYNC, _)) => self.install_packages(), Some((action::SYNC, _)) => self.install_packages(),
Some((args::UNMANAGED, _)) => self.show_unmanaged_packages(), Some((action::UNMANAGED, _)) => self.show_unmanaged_packages(),
Some((args::VERSION, _)) => self.show_version(), Some((action::VERSION, _)) => self.show_version(),
_ => todo!(), _ => todo!(),
} }
} }
+2 -1
View File
@@ -1,3 +1,4 @@
mod action;
pub mod args; pub mod args;
mod cmd; mod cmd;
mod core; mod core;
@@ -7,6 +8,6 @@ mod package;
mod ui; mod ui;
pub use crate::core::Pacdef; pub use crate::core::Pacdef;
pub use args::get_matched_arguments; pub use args::get_args;
pub use group::Group; pub use group::Group;
pub use package::Package; pub use package::Package;
+1 -1
View File
@@ -3,7 +3,7 @@ use anyhow::Result;
use pacdef::{args, Group, Pacdef}; use pacdef::{args, Group, Pacdef};
fn main() -> Result<()> { fn main() -> Result<()> {
let args = args::get_matched_arguments(); let args = args::get_args();
let groups = Group::load_from_dir(); let groups = Group::load_from_dir();
let pacdef = Pacdef::new(args, groups); let pacdef = Pacdef::new(args, groups);
pacdef.run_action_from_arg(); pacdef.run_action_from_arg();