2016-02-05 13:40:41 +01:00
|
|
|
// Copyright 2015, 2016 Ethcore (UK) Ltd.
|
|
|
|
// This file is part of Parity.
|
|
|
|
|
|
|
|
// Parity is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
|
|
|
// Parity is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with Parity. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
2016-01-27 17:18:38 +01:00
|
|
|
//! Ethcore client application.
|
|
|
|
|
|
|
|
#![warn(missing_docs)]
|
2016-03-11 11:16:49 +01:00
|
|
|
#![cfg_attr(feature="dev", feature(plugin))]
|
|
|
|
#![cfg_attr(feature="dev", plugin(clippy))]
|
2016-04-06 10:07:24 +02:00
|
|
|
#![cfg_attr(feature="dev", allow(useless_format))]
|
2016-07-10 13:18:33 +02:00
|
|
|
#![cfg_attr(feature="dev", allow(match_bool))]
|
2016-04-21 13:12:43 +02:00
|
|
|
|
2016-01-23 23:53:20 +01:00
|
|
|
extern crate docopt;
|
2016-03-22 19:12:17 +01:00
|
|
|
extern crate num_cpus;
|
2016-01-23 23:53:20 +01:00
|
|
|
extern crate rustc_serialize;
|
2016-07-29 10:48:05 +02:00
|
|
|
extern crate ethcore_devtools as devtools;
|
|
|
|
#[macro_use]
|
2015-12-22 22:19:50 +01:00
|
|
|
extern crate ethcore_util as util;
|
2016-01-07 16:08:12 +01:00
|
|
|
extern crate ethcore;
|
2016-01-29 15:56:06 +01:00
|
|
|
extern crate ethsync;
|
2016-02-18 12:42:01 +01:00
|
|
|
#[macro_use]
|
2016-01-31 11:08:04 +01:00
|
|
|
extern crate log as rlog;
|
2016-01-09 23:21:57 +01:00
|
|
|
extern crate env_logger;
|
2016-07-25 16:09:47 +02:00
|
|
|
extern crate ethcore_logger;
|
2016-01-22 00:11:19 +01:00
|
|
|
extern crate ctrlc;
|
2016-02-05 13:49:36 +01:00
|
|
|
extern crate fdlimit;
|
2016-02-23 20:14:37 +01:00
|
|
|
extern crate time;
|
2016-02-25 14:09:39 +01:00
|
|
|
extern crate number_prefix;
|
2016-03-09 14:11:15 +01:00
|
|
|
extern crate rpassword;
|
2016-04-10 15:12:20 +02:00
|
|
|
extern crate semver;
|
2016-08-05 10:32:04 +02:00
|
|
|
extern crate ethcore_io as io;
|
2016-04-13 18:03:57 +02:00
|
|
|
extern crate ethcore_ipc as ipc;
|
|
|
|
extern crate ethcore_ipc_nano as nanoipc;
|
2016-04-21 16:45:04 +02:00
|
|
|
#[macro_use]
|
|
|
|
extern crate hyper; // for price_info.rs
|
2016-05-04 15:37:09 +02:00
|
|
|
extern crate json_ipc_server as jsonipc;
|
2016-03-28 00:49:35 +02:00
|
|
|
|
2016-07-09 17:18:34 +02:00
|
|
|
extern crate ethcore_ipc_hypervisor as hypervisor;
|
2016-04-21 13:12:43 +02:00
|
|
|
extern crate ethcore_rpc;
|
|
|
|
|
2016-07-11 17:11:49 +02:00
|
|
|
extern crate ethcore_signer;
|
|
|
|
extern crate ansi_term;
|
2016-07-13 09:05:26 +02:00
|
|
|
#[macro_use]
|
|
|
|
extern crate lazy_static;
|
|
|
|
extern crate regex;
|
2016-07-15 10:11:14 +02:00
|
|
|
extern crate isatty;
|
2016-07-11 17:11:49 +02:00
|
|
|
|
2016-05-26 18:21:15 +02:00
|
|
|
#[cfg(feature = "dapps")]
|
|
|
|
extern crate ethcore_dapps;
|
2016-01-20 04:19:38 +01:00
|
|
|
|
2016-07-25 16:09:47 +02:00
|
|
|
mod cache;
|
2016-04-10 15:12:20 +02:00
|
|
|
mod upgrade;
|
2016-04-21 13:12:43 +02:00
|
|
|
mod rpc;
|
2016-05-26 18:21:15 +02:00
|
|
|
mod dapps;
|
2016-04-21 13:57:27 +02:00
|
|
|
mod informant;
|
|
|
|
mod io_handler;
|
2016-04-21 15:41:25 +02:00
|
|
|
mod cli;
|
2016-04-21 16:45:04 +02:00
|
|
|
mod configuration;
|
2016-05-26 18:24:51 +02:00
|
|
|
mod migration;
|
2016-05-27 13:03:00 +02:00
|
|
|
mod signer;
|
2016-06-01 19:37:34 +02:00
|
|
|
mod rpc_apis;
|
2016-06-14 16:12:46 +02:00
|
|
|
mod url;
|
2016-07-25 16:09:47 +02:00
|
|
|
mod helpers;
|
|
|
|
mod params;
|
|
|
|
mod deprecated;
|
|
|
|
mod dir;
|
2016-07-16 14:24:57 +02:00
|
|
|
mod modules;
|
2016-07-25 16:09:47 +02:00
|
|
|
mod account;
|
|
|
|
mod blockchain;
|
|
|
|
mod presale;
|
|
|
|
mod run;
|
2016-07-26 00:21:08 +02:00
|
|
|
mod sync;
|
2016-08-05 17:00:46 +02:00
|
|
|
mod snapshot;
|
2016-04-21 16:45:04 +02:00
|
|
|
|
2016-07-25 16:09:47 +02:00
|
|
|
use std::{process, env};
|
2016-04-21 16:45:04 +02:00
|
|
|
use cli::print_version;
|
2016-07-25 16:09:47 +02:00
|
|
|
use configuration::{Cmd, Configuration};
|
|
|
|
use deprecated::find_deprecated;
|
|
|
|
|
|
|
|
fn execute(command: Cmd) -> Result<String, String> {
|
|
|
|
match command {
|
|
|
|
Cmd::Run(run_cmd) => {
|
|
|
|
try!(run::execute(run_cmd));
|
|
|
|
Ok("".into())
|
2016-04-21 15:41:25 +02:00
|
|
|
},
|
2016-07-25 16:09:47 +02:00
|
|
|
Cmd::Version => Ok(print_version()),
|
|
|
|
Cmd::Account(account_cmd) => account::execute(account_cmd),
|
|
|
|
Cmd::ImportPresaleWallet(presale_cmd) => presale::execute(presale_cmd),
|
|
|
|
Cmd::Blockchain(blockchain_cmd) => blockchain::execute(blockchain_cmd),
|
|
|
|
Cmd::SignerToken(path) => signer::new_token(path),
|
2016-08-05 17:00:46 +02:00
|
|
|
Cmd::Snapshot(snapshot_cmd) => snapshot::execute(snapshot_cmd),
|
2016-05-26 18:24:51 +02:00
|
|
|
}
|
2016-04-21 15:41:25 +02:00
|
|
|
}
|
|
|
|
|
2016-07-25 16:09:47 +02:00
|
|
|
fn start() -> Result<String, String> {
|
|
|
|
let conf = Configuration::parse(env::args()).unwrap_or_else(|e| e.exit());
|
2016-04-21 15:41:25 +02:00
|
|
|
|
2016-07-25 16:09:47 +02:00
|
|
|
let deprecated = find_deprecated(&conf.args);
|
|
|
|
for d in deprecated {
|
|
|
|
println!("{}", d);
|
2016-06-14 16:12:46 +02:00
|
|
|
}
|
|
|
|
|
2016-07-25 16:09:47 +02:00
|
|
|
let cmd = try!(conf.into_command());
|
|
|
|
execute(cmd)
|
2016-05-23 18:42:59 +02:00
|
|
|
}
|
|
|
|
|
2016-07-25 16:09:47 +02:00
|
|
|
fn main() {
|
2016-07-26 00:21:08 +02:00
|
|
|
// just redirect to the sync::main()
|
2016-07-26 20:31:25 +02:00
|
|
|
if std::env::args().nth(1).map_or(false, |arg| arg == "sync") {
|
2016-07-26 00:21:08 +02:00
|
|
|
sync::main();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-07-25 16:09:47 +02:00
|
|
|
match start() {
|
|
|
|
Ok(result) => {
|
2016-07-29 13:35:27 +02:00
|
|
|
println!("{}", result);
|
2016-05-24 20:29:19 +02:00
|
|
|
},
|
2016-07-25 16:09:47 +02:00
|
|
|
Err(err) => {
|
2016-07-29 13:35:27 +02:00
|
|
|
println!("{}", err);
|
2016-07-25 16:09:47 +02:00
|
|
|
process::exit(1);
|
2016-05-24 20:29:19 +02:00
|
|
|
}
|
|
|
|
}
|
2016-06-07 17:21:19 +02:00
|
|
|
}
|