diff --git a/src/main.rs b/src/main.rs index 44e3495..cd78a77 100644 --- a/src/main.rs +++ b/src/main.rs @@ -77,7 +77,11 @@ fn parse_args() -> Command { .help("The multiaddr of the remote peer"), ); - app = app.subcommand(serve).subcommand(create_tunnel_server); + app = app + .arg_required_else_help(true) + .subcommand(serve) + .subcommand(create_tunnel_server); + app } @@ -176,13 +180,15 @@ async fn main() { .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) .try_init(); - let args = parse_args().get_matches(); - - if let Some(args) = args.subcommand_matches("serve") { - serve(args).await; - } + let cmd = parse_args(); - if let Some(args) = args.subcommand_matches("create_tunnel_server") { - create_tunnel_server(args).await; + match cmd.get_matches().subcommand() { + Some(("serve", args)) => { + serve(args).await; + } + Some(("create_tunnel_server", args)) => { + create_tunnel_server(args).await; + } + _ => unreachable!(), } }