Merge pull request #205 from ethcore/cleanerclioptions
Autogenerate the Args from the docopt macro.
This commit is contained in:
commit
d649f1aca9
@ -21,6 +21,7 @@ evmjit = { path = "rust-evmjit", optional = true }
|
||||
ethash = { path = "ethash" }
|
||||
num_cpus = "0.2"
|
||||
docopt = "0.6"
|
||||
docopt_macros = "0.6"
|
||||
ctrlc = "1.0"
|
||||
clippy = "0.0.37"
|
||||
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit e838fd90998fc5502d0b7c9427a4c231f9a6953d
|
||||
Subproject commit dc86e6359675440aea59ddb48648a01c799925d8
|
@ -1,7 +1,5 @@
|
||||
#![feature(plugin)]
|
||||
// TODO: uncomment once this can be made to work.
|
||||
//#![plugin(docopt_macros)]
|
||||
|
||||
#![plugin(docopt_macros)]
|
||||
extern crate docopt;
|
||||
extern crate rustc_serialize;
|
||||
extern crate ethcore_util as util;
|
||||
@ -20,9 +18,8 @@ use ethcore::service::{ClientService, NetSyncMessage};
|
||||
use ethcore::ethereum;
|
||||
use ethcore::blockchain::CacheSize;
|
||||
use ethcore::sync::EthSync;
|
||||
use docopt::Docopt;
|
||||
|
||||
const USAGE: &'static str = "
|
||||
docopt!(Args derive Debug, "
|
||||
Parity. Ethereum Client.
|
||||
|
||||
Usage:
|
||||
@ -32,15 +29,9 @@ Usage:
|
||||
Options:
|
||||
-l --logging LOGGING Specify the logging level
|
||||
-h --help Show this screen.
|
||||
";
|
||||
");
|
||||
|
||||
#[derive(Debug, RustcDecodable)]
|
||||
struct Args {
|
||||
arg_enode: Option<Vec<String>>,
|
||||
flag_logging: Option<String>,
|
||||
}
|
||||
|
||||
fn setup_log(init: &Option<String>) {
|
||||
fn setup_log(init: &String) {
|
||||
let mut builder = LogBuilder::new();
|
||||
builder.filter(None, LogLevelFilter::Info);
|
||||
|
||||
@ -48,22 +39,20 @@ fn setup_log(init: &Option<String>) {
|
||||
builder.parse(&env::var("RUST_LOG").unwrap());
|
||||
}
|
||||
|
||||
if let &Some(ref x) = init {
|
||||
builder.parse(x);
|
||||
}
|
||||
builder.parse(init);
|
||||
|
||||
builder.init().unwrap();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args: Args = Docopt::new(USAGE).and_then(|d| d.decode()).unwrap_or_else(|e| e.exit());
|
||||
let args: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit());
|
||||
|
||||
setup_log(&args.flag_logging);
|
||||
|
||||
let spec = ethereum::new_frontier();
|
||||
let init_nodes = match &args.arg_enode {
|
||||
&None => spec.nodes().clone(),
|
||||
&Some(ref enodes) => enodes.clone(),
|
||||
let init_nodes = match args.arg_enode.len() {
|
||||
0 => spec.nodes().clone(),
|
||||
_ => args.arg_enode.clone(),
|
||||
};
|
||||
let mut net_settings = NetworkConfiguration::new();
|
||||
net_settings.boot_nodes = init_nodes;
|
||||
|
Loading…
Reference in New Issue
Block a user