add import

This commit is contained in:
timeshifter
2023-01-11 14:49:03 +01:00
parent a4e8ce50f6
commit 951cc7ab66
5 changed files with 70 additions and 1 deletions
+20 -1
View File
@@ -1,4 +1,7 @@
use clap::{Arg, Command};
use std::path::PathBuf;
use clap::{Arg, ArgMatches, Command};
use path_absolutize::Absolutize;
use crate::action::*;
@@ -16,6 +19,12 @@ fn get_arg_parser() -> Command<'static> {
.arg(Arg::new("group").multiple_values(true)),
)
.subcommand(Command::new(GROUPS).about("show names of imported groups"))
.subcommand(
Command::new(IMPORT)
.about("import one or more group files")
.arg_required_else_help(true)
.arg(Arg::new("files").multiple_values(true)),
)
.subcommand(
Command::new(SHOW)
.about("show packages under an imported group")
@@ -35,3 +44,13 @@ fn get_arg_parser() -> Command<'static> {
pub fn get() -> clap::ArgMatches {
get_arg_parser().get_matches()
}
pub(crate) fn get_file_paths(arg_match: &ArgMatches) -> Vec<PathBuf> {
arg_match
.get_many::<String>("files")
.unwrap()
.cloned()
.map(PathBuf::from)
.map(|path| path.absolutize().unwrap().into_owned())
.collect()
}