move the structopt struct into the lib
This commit is contained in:
parent
3977c172db
commit
6b6087c4e9
3 changed files with 12 additions and 22 deletions
|
@ -1,8 +1,16 @@
|
|||
use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
pub struct Config {
|
||||
/// The root configuration directory for dip. This argument is required.
|
||||
#[structopt(short = "d", long = "root", parse(from_os_str))]
|
||||
pub root: PathBuf,
|
||||
/// A string containing the address to bind to. This defaults to "0.0.0.0:5000".
|
||||
#[structopt(short = "b", long = "bind", default_value = "0.0.0.0:5000")]
|
||||
pub bind: String,
|
||||
/// If a hook is specified here, it will be triggered manually exactly once and then the
|
||||
/// program will exit rather than running as a server.
|
||||
#[structopt(short = "h", long = "hook")]
|
||||
pub hook: Option<String>,
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ extern crate serde_json;
|
|||
#[macro_use]
|
||||
extern crate lazy_static;
|
||||
extern crate notify;
|
||||
#[macro_use]
|
||||
extern crate structopt;
|
||||
extern crate regex;
|
||||
extern crate toml;
|
||||
extern crate walkdir;
|
||||
|
|
24
src/main.rs
24
src/main.rs
|
@ -1,32 +1,12 @@
|
|||
#[macro_use]
|
||||
extern crate structopt;
|
||||
extern crate dip;
|
||||
extern crate failure;
|
||||
|
||||
use std::path::PathBuf;
|
||||
extern crate structopt;
|
||||
|
||||
use dip::Config;
|
||||
use failure::Error;
|
||||
use structopt::StructOpt;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
struct Opt {
|
||||
/// The root configuration directory for dip. This argument is required.
|
||||
#[structopt(short = "d", long = "root", parse(from_os_str))]
|
||||
root: PathBuf,
|
||||
/// A string containing the address to bind to. This defaults to "0.0.0.0:5000".
|
||||
#[structopt(short = "b", long = "bind")]
|
||||
bind: Option<String>,
|
||||
/// If a hook is specified here, it will be triggered manually exactly once and then the
|
||||
/// program will exit rather than running as a server.
|
||||
#[structopt(short = "h", long = "hook")]
|
||||
hook: Option<String>,
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
let opt = Opt::from_args();
|
||||
println!("{:?}", opt);
|
||||
|
||||
let config = Config::new(opt.root).bind(opt.bind).hook(opt.hook);
|
||||
let config = Config::from_args();
|
||||
dip::run(&config)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue