Finalized license, warranty flags

Made the clap Parser able to be run without a subcommand, by wrapping
the subcommand field of the Parser struct in an Option<Command>.

Further destructured the subcommand arms fields in main with Some(),
and made the default case None just return ().

Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
Christina Sørensen 2023-06-09 18:16:28 +02:00
parent c8ea855451
commit c38b524e09
Signed by: cafkafk
GPG key ID: CDDC792F655251ED
2 changed files with 10 additions and 9 deletions

View file

@ -29,7 +29,7 @@ const CONFIG_FILE: &str = "/.config/gg/config.yaml";
long_version=env!("CARGO_PKG_VERSION"),
about="GitOps for the masses",
long_about="A Rust GitOps and linkfarm orchestrator inspired by GNU Stow",
subcommand_required=true,
subcommand_required=false,
arg_required_else_help=true,
help_template="\
{before-help}{name} {version}
@ -59,7 +59,7 @@ pub struct Args {
pub code_of_conduct: bool,
#[command(subcommand)]
pub command: Commands,
pub command: Option<Commands>,
}
#[derive(Subcommand, Debug)]

View file

@ -42,27 +42,28 @@ fn main() {
_ => (),
}
match &args.command {
Commands::Link { msg: _ } => {
Some(Commands::Link { msg: _ }) => {
config.link_all();
}
Commands::Quick { msg } => {
Some(Commands::Quick { msg }) => {
config.quick(&msg.as_ref().unwrap());
}
Commands::Clone { msg: _ } => {
Some(Commands::Clone { msg: _ }) => {
config.clone_all();
}
Commands::Pull { msg: _ } => {
Some(Commands::Pull { msg: _ }) => {
config.pull_all();
}
Commands::Add { msg: _ } => {
Some(Commands::Add { msg: _ }) => {
config.add_all();
}
Commands::Commit { msg: _ } => {
Some(Commands::Commit { msg: _ }) => {
config.commit_all();
}
Commands::CommitMsg { msg } => {
Some(Commands::CommitMsg { msg }) => {
config.commit_all_msg(&msg.as_ref().unwrap());
}
None => (),
}
trace!("{:?}", config);
}