diff --git a/src/cmdline.rs b/src/cmdline.rs index 80a65a0..6136dce 100644 --- a/src/cmdline.rs +++ b/src/cmdline.rs @@ -1,11 +1,14 @@ -use structopt::StructOpt; +use std::path::PathBuf; +use structopt::{clap::AppSettings, StructOpt}; /// A standards-compliant bridge to Reolink IP cameras #[derive(StructOpt, Debug)] -#[structopt(name = "neolink")] +#[structopt(name = "neolink", setting(AppSettings::ArgRequiredElseHelp))] pub struct Opt { + #[structopt(short, long, parse(from_os_str))] + pub config: Option, #[structopt(subcommand)] - pub cmd: Command, + pub cmd: Option, } #[derive(StructOpt, Debug)] diff --git a/src/main.rs b/src/main.rs index 475475b..263bc38 100644 --- a/src/main.rs +++ b/src/main.rs @@ -32,17 +32,29 @@ fn main() -> Result<(), Error> { let opt = Opt::from_args(); - match opt.cmd { - Command::Rtsp(opts) => { + match (opt.cmd, opt.config) { + (None, None) => { + // Should be caught at the clap validation + unreachable!(); + } + (None, Some(config)) => { + warn!( + "Deprecated command line option. Please use: `neolink rtsp --config={:?}`", + config + ); + rtsp::main(rtsp::Opt { config })?; + } + (Some(_), Some(_)) => error!("--config should be given after the subcommand"), + (Some(Command::Rtsp(opts)), None) => { rtsp::main(opts)?; } - Command::StatusLight(opts) => { + (Some(Command::StatusLight(opts)), None) => { statusled::main(opts)?; } - Command::Reboot(opts) => { + (Some(Command::Reboot(opts)), None) => { reboot::main(opts)?; } - Command::Talk(opts) => { + (Some(Command::Talk(opts)), None) => { talk::main(opts)?; } }