Mercurial > hg
view rust/rhg/src/main.rs @ 45051:93e8e6e0b5fb
heptapod-ci: build rhg before tests run
Differential Revision: https://phab.mercurial-scm.org/D8682
author | Antoine Cezar <antoine.cezar@octobus.net> |
---|---|
date | Mon, 06 Jul 2020 09:30:26 +0200 |
parents | 18f8d3b31baa |
children | 47997afadf08 |
line wrap: on
line source
use clap::App; use clap::AppSettings; use clap::SubCommand; mod commands; mod error; mod exitcode; mod ui; use commands::Command; fn main() { let mut app = App::new("rhg") .setting(AppSettings::AllowInvalidUtf8) .setting(AppSettings::SubcommandRequired) .setting(AppSettings::VersionlessSubcommands) .version("0.0.1") .subcommand( SubCommand::with_name("root").about(commands::root::HELP_TEXT), ); let matches = app.clone().get_matches_safe().unwrap_or_else(|_| { std::process::exit(exitcode::UNIMPLEMENTED_COMMAND) }); let command_result = match matches.subcommand_name() { Some(name) => match name { "root" => commands::root::RootCommand::new().run(), _ => std::process::exit(exitcode::UNIMPLEMENTED_COMMAND), }, _ => { match app.print_help() { Ok(_) => std::process::exit(exitcode::OK), Err(_) => std::process::exit(exitcode::ABORT), }; } }; match command_result { Ok(_) => std::process::exit(exitcode::OK), Err(e) => e.exit(), } }