1use argh::{self, FromArgs};
2use std::path::PathBuf;
3
4#[derive(FromArgs, PartialEq, Debug)]
5pub struct AtomBlocksCli {
8 #[argh(subcommand)]
9 action: Option<CliActions>,
10
11 #[argh(switch, short = 'v', long = "verbose")]
13 verbose: bool,
14
15 #[argh(switch, long = "trace")]
17 trace: bool,
18
19 #[argh(switch, long = "version")]
21 version: bool,
22}
23
24impl AtomBlocksCli {
25 pub fn verbose(&self) -> bool {
26 self.verbose
27 }
28 pub fn trace(&self) -> bool {
29 self.trace
30 }
31 pub fn action(&self) -> Option<&CliActions> {
32 self.action.as_ref()
33 }
34 pub fn version(&self) -> bool {
35 self.version
36 }
37}
38
39#[derive(FromArgs, PartialEq, Debug)]
40#[argh(subcommand)]
41pub enum CliActions {
42 Run(CliActionRun),
43 Hit(CliActionHit),
44}
45
46#[derive(FromArgs, PartialEq, Debug)]
47#[argh(subcommand, name = "run")]
49pub struct CliActionRun {
50 #[argh(option, short = 'c', long = "config")]
52 config: Option<PathBuf>,
53}
54impl CliActionRun {
55 pub fn config(&self) -> Option<PathBuf> {
56 self.config.clone()
57 }
58}
59
60#[derive(FromArgs, PartialEq, Debug)]
61#[argh(subcommand, name = "hit")]
63pub struct CliActionHit {
64 #[argh(positional)]
66 id: u32,
67}
68impl CliActionHit {
69 pub fn id(&self) -> u32 {
70 self.id
71 }
72}