use anyhow::Result; use clap::{ArgMatches, Command}; use crate::utils::args::ArgExt as _; pub mod list; pub mod new; macro_rules! each_subcommand { ($mac:ident) => { $mac!(list); $mac!(new); }; } pub fn make_command(mut command: Command) -> Command { macro_rules! add_subcommand { ($name:ident) => {{ command = command.subcommand(crate::commands::deploys::$name::make_command( Command::new(stringify!($name).replace('_', "-")), )); }}; } command = command .about("Manage deployments for Sentry releases.") .subcommand_required(true) .arg_required_else_help(true) .org_arg() .project_arg(true) .release_arg(); each_subcommand!(add_subcommand); command } pub fn execute(matches: &ArgMatches) -> Result<()> { macro_rules! execute_subcommand { ($name:ident) => {{ if let Some(sub_matches) = matches.subcommand_matches(&stringify!($name).replace('_', "-")) { return crate::commands::deploys::$name::execute(&sub_matches); } }}; } each_subcommand!(execute_subcommand); unreachable!(); }