mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-15 02:42:38 +00:00
* upgrade clap to v4.5 * cli fixes * Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli * value parser for mnemonic * Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli * merge unstable * default --format val * fix eth sim * fix eth sim * merge conflicts * resolve beta compiler issue * add num args, version * add custom flag parser, make rate limiter flags clap friendly * remove unneeded check * fmt * update * alphabetic order * resolve merge conflict * fix test * resolve conflicts * fix test * revert removed if statement * fmt got me again * fix broken flag * make cli * make cli * update * remove -e files * update * cli help updates * Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli * cli help updates * md files * merge conflict * merge conflicts * md * help text, text width, and a few flag fixes * fmt * merge * revert * revert * resolve merge conflicts * merge conflicts * revert simulator changes * require at least one arg * fix eth sim cli * resolve merge conflicts * book changes * md changes * cli check * cli check * retry cli check * retry cli check * Merge branch 'unstable' of https://github.com/sigp/lighthouse into upgrade-clap-cli * cli * Merge remote-tracking branch 'origin/unstable' into upgrade-clap-cli * Update CLI docs for Goerli removal * Fix cargo lock
53 lines
1.5 KiB
Rust
53 lines
1.5 KiB
Rust
use crate::{config::Config, logger, server, updater};
|
|
use clap::{Arg, ArgAction, Command};
|
|
use clap_utils::get_color_style;
|
|
|
|
pub const SERVE: &str = "serve";
|
|
pub const RUN_UPDATER: &str = "run-updater";
|
|
pub const CONFIG: &str = "config";
|
|
|
|
fn run_updater() -> Command {
|
|
Command::new(RUN_UPDATER).styles(get_color_style())
|
|
}
|
|
|
|
fn serve() -> Command {
|
|
Command::new(SERVE).styles(get_color_style())
|
|
}
|
|
|
|
pub fn app() -> Command {
|
|
Command::new("beacon_watch_daemon")
|
|
.author("Sigma Prime <contact@sigmaprime.io>")
|
|
.styles(get_color_style())
|
|
.arg(
|
|
Arg::new(CONFIG)
|
|
.long(CONFIG)
|
|
.value_name("PATH_TO_CONFIG")
|
|
.help("Path to configuration file")
|
|
.action(ArgAction::Set)
|
|
.global(true),
|
|
)
|
|
.subcommand(run_updater())
|
|
.subcommand(serve())
|
|
}
|
|
|
|
pub async fn run() -> Result<(), String> {
|
|
let matches = app().get_matches();
|
|
|
|
let config = match matches.get_one::<String>(CONFIG) {
|
|
Some(path) => Config::load_from_file(path.to_string())?,
|
|
None => Config::default(),
|
|
};
|
|
|
|
logger::init_logger(&config.log_level);
|
|
|
|
match matches.subcommand() {
|
|
Some((RUN_UPDATER, _)) => updater::run_updater(config)
|
|
.await
|
|
.map_err(|e| format!("Failure: {:?}", e)),
|
|
Some((SERVE, _)) => server::serve(config)
|
|
.await
|
|
.map_err(|e| format!("Failure: {:?}", e)),
|
|
_ => Err("Unsupported subcommand. See --help".into()),
|
|
}
|
|
}
|