Skip to content
This repository was archived by the owner on Nov 6, 2020. It is now read-only.

Autogenerate the Args from the docopt macro. #205

Merged
merged 1 commit into from
Jan 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
2 changes: 1 addition & 1 deletion res/ethereum/tests
Submodule tests updated 32 files
+391 −390 BasicTests/difficultyCustomHomestead.json
+3,601 −7,440 BasicTests/difficultyFrontier.json
+3,600 −7,440 BasicTests/difficultyHomestead.json
+3,600 −7,440 BasicTests/difficultyMorden.json
+3,600 −7,440 BasicTests/difficultyOlimpic.json
+0 −6,077 BlockchainTests/Homestead/bcInvalidRLPTest.json
+1,685 −1,685 BlockchainTests/Homestead/bcWalletTest.json
+271 −281 StateTests/Homestead/stCallCodes.json
+38 −38 StateTests/Homestead/stCallCreateCallCodeTest.json
+209 −217 StateTests/Homestead/stCallDelegateCodes.json
+190 −198 StateTests/Homestead/stCallDelegateCodesCallCode.json
+0 −2,637 StateTests/Homestead/stDelegatecallTest.json
+5 −5 StateTests/Homestead/stHomeSteadSpecific.json
+17 −17 StateTests/Homestead/stInitCodeTest.json
+46 −46 StateTests/Homestead/stLogTests.json
+6 −6 StateTests/Homestead/stMemoryStressTest.json
+65 −65 StateTests/Homestead/stMemoryTest.json
+89 −89 StateTests/Homestead/stPreCompiledContracts.json
+15 −15 StateTests/Homestead/stQuadraticComplexityTest.json
+2 −2 StateTests/Homestead/stRecursiveCreate.json
+17 −17 StateTests/Homestead/stRefundTest.json
+9 −9 StateTests/Homestead/stSpecialTest.json
+74 −66 StateTests/Homestead/stSystemOperationsTest.json
+40 −40 StateTests/Homestead/stTransactionTest.json
+84 −84 StateTests/Homestead/stWalletTest.json
+292 −869 StateTests/stCallCodes.json
+13 −5 StateTests/stCallCreateCallCodeTest.json
+16 −8 StateTests/stSystemOperationsTest.json
+11 −11 StateTests/stTransitionTest.json
+1 −1 TransactionTests/Homestead/tt10mbDataField.json
+57 −57 TransactionTests/Homestead/ttTransactionTest.json
+69 −69 TransactionTests/Homestead/ttWrongRLPTransaction.json
29 changes: 9 additions & 20 deletions src/bin/client/main.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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:
Expand All @@ -32,38 +29,30 @@ 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);

if env::var("RUST_LOG").is_ok() {
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;
Expand Down