feat(export): docstrings, man, README, switches

This commit is contained in:
steven-omaha
2023-06-06 15:30:24 +02:00
parent 0610cd0731
commit 4843543a74
6 changed files with 133 additions and 15 deletions
+13
View File
@@ -34,6 +34,19 @@ fn get_group_cmd() -> Command {
let export = Command::new("export")
.about("export one or more group files")
.arg_required_else_help(true)
.arg(
Arg::new("force")
.short('f')
.long("force")
.action(clap::ArgAction::SetTrue)
.help("overwrite output files if they exist"),
)
.arg(
Arg::new("output_dir")
.short('o')
.long("output")
.help("(optional) the directory under which to save the group"),
)
.arg(
Arg::new("groups")
.num_args(1..)
+7 -2
View File
@@ -8,8 +8,7 @@ pub enum Arguments {
#[derive(Debug)]
pub enum GroupAction {
Edit(Groups),
// TODO: optional output dir
Export(Groups),
Export(Groups, OutputDir, Force),
Import(Groups),
List,
New(Groups, Edit),
@@ -40,3 +39,9 @@ pub struct Edit(pub bool);
#[derive(Debug)]
pub struct Noconfirm(pub bool);
#[derive(Debug)]
pub struct Force(pub bool);
#[derive(Debug)]
pub struct OutputDir(pub Option<String>);
+9 -1
View File
@@ -17,7 +17,7 @@ fn parse_group_args(args: &clap::ArgMatches) -> GroupAction {
match args.subcommand() {
Some(("edit", args)) => Edit(get_groups(args)),
Some(("export", args)) => Export(get_groups(args)),
Some(("export", args)) => Export(get_groups(args), get_output_dir(args), get_force(args)),
Some(("import", args)) => Import(get_groups(args)),
Some(("list", _)) => List,
Some(("new", args)) => New(get_groups(args), get_edit(args)),
@@ -69,3 +69,11 @@ fn get_groups(args: &clap::ArgMatches) -> Groups {
.collect(),
)
}
fn get_output_dir(args: &clap::ArgMatches) -> OutputDir {
OutputDir(args.get_one::<String>("output_dir").cloned())
}
fn get_force(args: &clap::ArgMatches) -> Force {
Force(get_one_arg(args, "force"))
}