diff --git a/src/action.rs b/src/action.rs new file mode 100644 index 0000000..7f8c6dd --- /dev/null +++ b/src/action.rs @@ -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"; diff --git a/src/args.rs b/src/args.rs index 5c1056d..48c7310 100644 --- a/src/args.rs +++ b/src/args.rs @@ -1,10 +1,6 @@ use clap::{Arg, Command}; -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"; +use crate::action::*; fn get_arg_parser() -> Command<'static> { let result = Command::new("pacdef") @@ -28,6 +24,6 @@ fn get_arg_parser() -> Command<'static> { result } -pub fn get_matched_arguments() -> clap::ArgMatches { +pub fn get_args() -> clap::ArgMatches { get_arg_parser().get_matches() } diff --git a/src/core.rs b/src/core.rs index 70d271b..589b371 100644 --- a/src/core.rs +++ b/src/core.rs @@ -2,7 +2,7 @@ use std::collections::HashSet; use std::path::PathBuf; use std::process::exit; -use crate::args; +use crate::action; use crate::cmd::run_install_command; use crate::db::{get_all_installed_packages, get_explicitly_installed_packages}; use crate::group::{Group, GROUPS_DIR}; @@ -64,11 +64,11 @@ impl Pacdef { pub fn run_action_from_arg(self) { match self.args.subcommand() { // Some((args::EDIT, groups)) => println!("{groups:#?}"), - Some((args::EDIT, groups)) => self.edit_group_files(groups), - Some((args::GROUPS, _)) => self.show_groups(), - Some((args::SYNC, _)) => self.install_packages(), - Some((args::UNMANAGED, _)) => self.show_unmanaged_packages(), - Some((args::VERSION, _)) => self.show_version(), + Some((action::EDIT, groups)) => self.edit_group_files(groups), + Some((action::GROUPS, _)) => self.show_groups(), + Some((action::SYNC, _)) => self.install_packages(), + Some((action::UNMANAGED, _)) => self.show_unmanaged_packages(), + Some((action::VERSION, _)) => self.show_version(), _ => todo!(), } } diff --git a/src/lib.rs b/src/lib.rs index 0e9a96a..9965036 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,3 +1,4 @@ +mod action; pub mod args; mod cmd; mod core; @@ -7,6 +8,6 @@ mod package; mod ui; pub use crate::core::Pacdef; -pub use args::get_matched_arguments; +pub use args::get_args; pub use group::Group; pub use package::Package; diff --git a/src/main.rs b/src/main.rs index 99c7762..f4efb0e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3,7 +3,7 @@ use anyhow::Result; use pacdef::{args, Group, Pacdef}; fn main() -> Result<()> { - let args = args::get_matched_arguments(); + let args = args::get_args(); let groups = Group::load_from_dir(); let pacdef = Pacdef::new(args, groups); pacdef.run_action_from_arg();