diff --git a/src/cli.rs b/src/cli.rs index bfd54c5..c70b9a3 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -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, } #[derive(Subcommand, Debug)] diff --git a/src/main.rs b/src/main.rs index 533899b..4005214 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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); }