Implement real command line arguments
This commit is contained in:
1 parent
ec1e69e49c
commit
b2739c5e12
3 files changed
+17
-3
No files matched your search
@@ -16,6 +16,7 @@ indoc = "0.3.5"
|
||||
md5 = "0.7.0"
|
||||
nom = "5.1.1"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
structopt = "0.3"
|
||||
toml = "0.5"
|
||||
yaserde = { git = "https://github.com/media-io/yaserde.git" }
|
||||
yaserde_derive = { git = "https://github.com/media-io/yaserde.git" }
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
use std::path::PathBuf;
|
||||
use structopt::StructOpt;
|
||||
|
||||
/// A standards-compliant bridge to Reolink IP cameras
|
||||
#[derive(StructOpt, Debug)]
|
||||
#[structopt(name = "neolink")]
|
||||
pub struct Opt {
|
||||
/// main configuration file
|
||||
#[structopt(short, long, parse(from_os_str))]
|
||||
pub config: PathBuf,
|
||||
}
|
||||
+5
-3
@@ -1,14 +1,16 @@
|
||||
mod bc;
|
||||
mod bc_protocol;
|
||||
mod config;
|
||||
mod cmdline;
|
||||
|
||||
use bc_protocol::BcCamera;
|
||||
use config::{Config, CameraConfig};
|
||||
use cmdline::Opt;
|
||||
use crossbeam_utils::thread;
|
||||
use err_derive::Error;
|
||||
use std::env::args;
|
||||
use std::fs;
|
||||
use std::net::TcpListener;
|
||||
use structopt::StructOpt;
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
pub enum Error {
|
||||
@@ -21,8 +23,8 @@ pub enum Error {
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
let config_path = args().nth(1).expect("A config file must be supplied on the command line");
|
||||
let config: Config = toml::from_str(&fs::read_to_string(config_path)?)?;
|
||||
let opt = Opt::from_args();
|
||||
let config: Config = toml::from_str(&fs::read_to_string(opt.config)?)?;
|
||||
|
||||
thread::scope(|s| {
|
||||
for camera in config.cameras {
|
||||
|
||||
Reference in new issue
Block a user