hermes_cli/
application.rs1use std::path::{Path, PathBuf};
2
3use hermes_cli_framework::application::Application;
4use hermes_cli_framework::command::CommandRunner;
5use hermes_cli_framework::output::Output;
6use hermes_runtime::types::runtime::HermesRuntime;
7
8use crate::commands::HermesCommand;
9use crate::config::HermesConfig;
10use crate::contexts::app::HermesApp;
11use crate::Result;
12
13#[derive(clap::Parser)]
14pub struct HermesCli {
15 #[clap(short = 'c', long = "config", default_value = "config.toml")]
16 pub config_path: PathBuf,
17
18 #[clap(long)]
19 pub json: bool,
20
21 #[clap(subcommand)]
22 pub command: HermesCommand,
23}
24
25impl Application for HermesCli {
26 type Config = HermesConfig;
27
28 type App = HermesApp;
29
30 type Command = HermesCommand;
31
32 fn config_path(&self) -> &Path {
33 &self.config_path
34 }
35
36 fn json_output(&self) -> bool {
37 self.json
38 }
39
40 fn parse_from_env() -> Self {
41 clap::Parser::parse()
42 }
43
44 async fn run(&self, runtime: HermesRuntime) -> Result<Output> {
45 let app = HermesApp {
46 runtime,
47 config_path: self.config_path.clone(),
48 };
49
50 self.command.run(&app).await
51 }
52}