Skip to content

Commit

Permalink
add start command
Browse files Browse the repository at this point in the history
  • Loading branch information
0o-de-lally committed May 10, 2021
1 parent ffe609c commit 509116d
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
8 changes: 7 additions & 1 deletion ol/cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ mod query_cmd;
mod health_cmd;
mod explorer_cmd;
mod pilot_cmd;
mod start_cmd;

use self::{
init_cmd::InitCmd,
Expand All @@ -31,6 +32,7 @@ use self::{
query_cmd::QueryCmd,
health_cmd::HealthCmd,
pilot_cmd::PilotCmd,
start_cmd::StartCmd,
};

use crate::entrypoint;
Expand Down Expand Up @@ -88,8 +90,12 @@ pub enum OlCliCmd {
Explorer(ExplorerCMD),

/// The `explorer` subcommand
#[options(help = "run the 0L services")]
#[options(help = "run pilot command, which triggers needed services")]
Pilot(PilotCmd),

/// The `start` subcommand
#[options(help = "start 0L services")]
Start(StartCmd),
}

/// This trait allows you to define how application configuration is loaded.
Expand Down
3 changes: 1 addition & 2 deletions ol/cli/src/commands/pilot_cmd.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
//! `monitor-cmd` subcommand
//! `pilot-cmd` subcommand
use abscissa_core::{Command, Options, Runnable};
use crate::{check, node::client, entrypoint, node::node::Node, prelude::app_config};

/// `pilot` subcommand

#[derive(Command, Debug, Options)]
pub struct PilotCmd {
Expand Down
28 changes: 28 additions & 0 deletions ol/cli/src/commands/start_cmd.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//! `start-cmd` subcommand
use abscissa_core::{Command, Options, Runnable};
use crate::{check, node::client, entrypoint, node::node::Node, prelude::app_config};

/// `pilot` subcommand
#[derive(Command, Debug, Options)]
pub struct StartCmd {
/// Runs once, defaults to continuous
#[options(short = "o", help = "run once and exit, not continuous")]
once: bool,
/// Silent mode, defaults to verbose
#[options(short = "s", help = "run once and exit, not continuous")]
silent: bool
}

impl Runnable for StartCmd {
/// Start the application.
fn run(&self) {
let args = entrypoint::get_args();
let cfg = app_config().clone();
let client = client::pick_client(args.swarm_path, &cfg).unwrap().0;
let mut node = Node::new(client, cfg);

check::runner::run_checks(&mut node, true ,!self.once, !self.silent);
}
}

0 comments on commit 509116d

Please sign in to comment.