Merge pull request #205 from ethcore/cleanerclioptions
Autogenerate the Args from the docopt macro.
This commit is contained in:
@@ -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"
|
||||
|
||||
|
||||
Submodule res/ethereum/tests updated: e838fd9099...dc86e63596
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user