Use yaml.

This commit is contained in:
Tomasz Drwięga
2017-11-10 12:36:47 +01:00
parent 5c57479348
commit da44b3fcfa
5 changed files with 37 additions and 17 deletions
+15
View File
@@ -0,0 +1,15 @@
name: polkadot
version: "1.0.0"
author: "Parity Team <admin@polkadot.io>"
about: Polkadot Node Rust Implementation
args:
- log:
short: l
value_name: LOG_PATTERN
help: Sets a custom logging
takes_value: true
subcommands:
- collator:
about: Run collator node
- validator:
about: Run validator node
+11 -14
View File
@@ -14,35 +14,32 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.
extern crate clap;
extern crate env_logger;
#[macro_use]
extern crate clap;
#[macro_use]
extern crate log;
use clap::{Arg, App, SubCommand};
pub fn main() {
let matches = App::new("Polkadot")
.arg(Arg::with_name("log")
.short("l")
.value_name("LOG")
.help("Sets logging.")
.takes_value(true))
.subcommand(SubCommand::with_name("collator"))
.subcommand(SubCommand::with_name("validator"))
.get_matches();
let yaml = load_yaml!("./cli.yml");
let matches = clap::App::from_yaml(yaml).get_matches();
let log_pattern = matches.value_of("log").unwrap_or("");
init_logger(log_pattern);
if let Some(_) = matches.subcommand_matches("collator") {
println!("Running collator.");
info!("Starting collator.");
return;
}
if let Some(_) = matches.subcommand_matches("validator") {
println!("Running collator.");
info!("Starting validator.");
return;
}
println!("No command given.\n");
let _ = clap::App::from_yaml(yaml).print_long_help();
}