63 lines
1.1 KiB
Rust
63 lines
1.1 KiB
Rust
|
#[macro_use]
|
||
|
extern crate futures;
|
||
|
extern crate serde;
|
||
|
#[macro_use]
|
||
|
extern crate serde_derive;
|
||
|
extern crate toml;
|
||
|
extern crate web3;
|
||
|
extern crate docopt;
|
||
|
|
||
|
mod config;
|
||
|
mod data;
|
||
|
mod error;
|
||
|
|
||
|
use std::env;
|
||
|
use std::path::PathBuf;
|
||
|
use docopt::Docopt;
|
||
|
use config::Config;
|
||
|
use error::Error;
|
||
|
|
||
|
const USAGE: &'static str = r#"
|
||
|
Ethereum-Kovan bridge.
|
||
|
Copyright 2017 Parity Technologies (UK) Limited
|
||
|
|
||
|
Usage:
|
||
|
bridge --config <config> --database <database>
|
||
|
bridge -h | --help
|
||
|
|
||
|
Options:
|
||
|
-h, --help Display help message and exit.
|
||
|
"#;
|
||
|
|
||
|
#[derive(Debug, Deserialize)]
|
||
|
pub struct Args {
|
||
|
arg_config: Option<PathBuf>,
|
||
|
arg_database: PathBuf,
|
||
|
}
|
||
|
|
||
|
fn main() {
|
||
|
let result = execute(env::args());
|
||
|
|
||
|
match result {
|
||
|
Ok(s) => println!("{}", s),
|
||
|
Err(err) => println!("{}", err),
|
||
|
}
|
||
|
}
|
||
|
|
||
|
fn execute<S, I>(command: I) -> Result<String, Error> where I: IntoIterator<Item=S>, S: AsRef<str> {
|
||
|
let args: Args = Docopt::new(USAGE)
|
||
|
.and_then(|d| d.argv(command).deserialize())?;
|
||
|
|
||
|
let config = match args.arg_config {
|
||
|
Some(path) => Config::load(path)?,
|
||
|
None => Config::default(),
|
||
|
};
|
||
|
|
||
|
Ok("Done".into())
|
||
|
}
|
||
|
|
||
|
|
||
|
#[cfg(test)]
|
||
|
mod tests {
|
||
|
}
|