add import
This commit is contained in:
+20
-1
@@ -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()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user