2020-03-05 16:53:25 +00:00
|
|
|
// This file is part of Substrate.
|
|
|
|
|
2020-05-16 13:32:11 +00:00
|
|
|
// Copyright (C) 2017-2020 Parity Technologies (UK) Ltd.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
2020-03-05 16:53:25 +00:00
|
|
|
|
|
|
|
use crate::chain_spec;
|
|
|
|
use crate::cli::Cli;
|
2020-04-15 11:33:19 +00:00
|
|
|
use crate::service;
|
|
|
|
use sc_cli::SubstrateCli;
|
2020-03-05 16:53:25 +00:00
|
|
|
|
2020-04-15 11:33:19 +00:00
|
|
|
impl SubstrateCli for Cli {
|
|
|
|
fn impl_name() -> &'static str {
|
|
|
|
"Substrate Node"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn impl_version() -> &'static str {
|
|
|
|
env!("SUBSTRATE_CLI_IMPL_VERSION")
|
|
|
|
}
|
2020-03-05 16:53:25 +00:00
|
|
|
|
2020-04-15 11:33:19 +00:00
|
|
|
fn description() -> &'static str {
|
|
|
|
env!("CARGO_PKG_DESCRIPTION")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn author() -> &'static str {
|
|
|
|
env!("CARGO_PKG_AUTHORS")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn support_url() -> &'static str {
|
|
|
|
"support.anonymous.an"
|
|
|
|
}
|
2020-03-05 16:53:25 +00:00
|
|
|
|
2020-04-15 11:33:19 +00:00
|
|
|
fn copyright_start_year() -> i32 {
|
|
|
|
2017
|
|
|
|
}
|
|
|
|
|
|
|
|
fn executable_name() -> &'static str {
|
|
|
|
env!("CARGO_PKG_NAME")
|
|
|
|
}
|
|
|
|
|
|
|
|
fn load_spec(&self, id: &str) -> Result<Box<dyn sc_service::ChainSpec>, String> {
|
|
|
|
Ok(match id {
|
|
|
|
"dev" => Box::new(chain_spec::development_config()),
|
|
|
|
"" | "local" => Box::new(chain_spec::local_testnet_config()),
|
|
|
|
path => Box::new(chain_spec::ChainSpec::from_json_file(
|
|
|
|
std::path::PathBuf::from(path),
|
|
|
|
)?),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Parse and run command line arguments
|
|
|
|
pub fn run() -> sc_cli::Result<()> {
|
|
|
|
let cli = Cli::from_args();
|
|
|
|
|
|
|
|
match &cli.subcommand {
|
2020-03-05 16:53:25 +00:00
|
|
|
Some(subcommand) => {
|
2020-04-15 11:33:19 +00:00
|
|
|
let runner = cli.create_runner(subcommand)?;
|
|
|
|
runner.run_subcommand(subcommand, |config| Ok(new_full_start!(config).0))
|
|
|
|
}
|
2020-03-05 16:53:25 +00:00
|
|
|
None => {
|
2020-04-15 11:33:19 +00:00
|
|
|
let runner = cli.create_runner(&cli.run)?;
|
|
|
|
runner.run_node(
|
2020-03-05 16:53:25 +00:00
|
|
|
service::new_light,
|
|
|
|
service::new_full,
|
2020-04-15 11:33:19 +00:00
|
|
|
node_template_runtime::VERSION
|
2020-03-05 16:53:25 +00:00
|
|
|
)
|
2020-04-15 11:33:19 +00:00
|
|
|
}
|
2020-03-05 16:53:25 +00:00
|
|
|
}
|
|
|
|
}
|