2017-06-25 04:21:13 -07:00
|
|
|
#[macro_use]
|
|
|
|
extern crate futures;
|
|
|
|
extern crate serde;
|
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_derive;
|
|
|
|
extern crate toml;
|
|
|
|
extern crate web3;
|
|
|
|
extern crate docopt;
|
2017-08-01 02:36:48 -07:00
|
|
|
extern crate tokio_core;
|
2017-06-25 04:21:13 -07:00
|
|
|
|
2017-08-01 02:36:48 -07:00
|
|
|
mod api;
|
|
|
|
mod app;
|
2017-06-25 04:21:13 -07:00
|
|
|
mod config;
|
2017-08-01 02:36:48 -07:00
|
|
|
mod database;
|
2017-06-25 04:21:13 -07:00
|
|
|
mod error;
|
2017-08-01 02:36:48 -07:00
|
|
|
//mod l;
|
|
|
|
pub mod actions;
|
2017-06-25 04:21:13 -07:00
|
|
|
|
|
|
|
use std::env;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use docopt::Docopt;
|
2017-08-01 02:36:48 -07:00
|
|
|
use app::App;
|
2017-06-25 04:21:13 -07:00
|
|
|
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(),
|
|
|
|
};
|
|
|
|
|
2017-08-01 02:36:48 -07:00
|
|
|
let app = App::new_ipc(config, args.arg_database)?;
|
|
|
|
|
2017-06-25 04:21:13 -07:00
|
|
|
Ok("Done".into())
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
}
|