From 97359801c2550d1f11448769f873aa65b0d8ce34 Mon Sep 17 00:00:00 2001 From: Tangent 128 Date: Wed, 11 Apr 2018 01:50:18 -0400 Subject: [PATCH] Print help by default --- src/commands/relay.rs | 2 +- src/main.rs | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/commands/relay.rs b/src/commands/relay.rs index 93dd108..282f024 100644 --- a/src/commands/relay.rs +++ b/src/commands/relay.rs @@ -109,7 +109,7 @@ impl Service for RelayServer { } } -pub fn args() -> App<'static, 'static> { +pub fn options() -> App<'static, 'static> { SubCommand::with_name("relay") .about("Hosts an HTTP-based relay server") .arg(Arg::with_name("listen") diff --git a/src/main.rs b/src/main.rs index bfd104a..9975024 100644 --- a/src/main.rs +++ b/src/main.rs @@ -8,17 +8,22 @@ mod commands; use clap::{App, AppSettings}; use commands::{relay}; -fn main() { - let args = App::new("webmetro") +fn options() -> App<'static, 'static> { + App::new("webmetro") .version(crate_version!()) .about("Utilities for broadcasting & relaying live WebM video/audio streams") - .setting(AppSettings::SubcommandRequired) .setting(AppSettings::VersionlessSubcommands) - .subcommand(relay::args()) - .get_matches(); + .subcommand(relay::options()) +} + +fn main() { + let args = options().get_matches(); match args.subcommand() { ("relay", Some(sub_args)) => relay::run(sub_args), - _ => {} + _ => { + options().print_help().unwrap(); + println!("") + } } }