seaplane_cli/cli/cmds/
formation.rs

1pub mod common;
2#[cfg(feature = "unstable")]
3mod configuration;
4#[cfg(feature = "unstable")]
5mod container_stats;
6mod delete;
7mod fetch;
8mod land;
9mod launch;
10mod list;
11#[cfg(feature = "unstable")]
12mod load_balance;
13mod plan;
14mod status;
15#[cfg(feature = "unstable")]
16mod template;
17
18use clap::{ArgMatches, Command};
19pub use common::{Provider, Region};
20pub use plan::SeaplaneFormationPlanArgMatches;
21
22#[cfg(feature = "unstable")]
23use self::{
24    configuration::SeaplaneFormationConfiguration,
25    container_stats::SeaplaneFormationContainerStatistics,
26    load_balance::SeaplaneFormationLoadBalance, template::SeaplaneFormationTemplate,
27};
28pub use self::{
29    delete::SeaplaneFormationDelete, fetch::SeaplaneFormationFetch, land::SeaplaneFormationLand,
30    launch::SeaplaneFormationLaunch, list::SeaplaneFormationList, plan::SeaplaneFormationPlan,
31    status::SeaplaneFormationStatus,
32};
33use crate::{cli::CliCommand, error::Result, Ctx};
34
35#[derive(Copy, Clone, Debug)]
36pub struct SeaplaneFormation;
37
38impl SeaplaneFormation {
39    pub fn command() -> Command {
40        #[cfg_attr(not(feature = "unstable"), allow(unused_mut))]
41        let mut app = Command::new("formation")
42            .about(
43                "Operate on local Formations Plans and remote Formation Instances of those Plans",
44            )
45            .subcommand_required(true)
46            .arg_required_else_help(true)
47            .subcommand(SeaplaneFormationPlan::command())
48            .subcommand(SeaplaneFormationDelete::command())
49            .subcommand(SeaplaneFormationFetch::command())
50            .subcommand(SeaplaneFormationLand::command())
51            .subcommand(SeaplaneFormationLaunch::command())
52            .subcommand(SeaplaneFormationList::command())
53            .subcommand(SeaplaneFormationStatus::command());
54
55        #[cfg(feature = "unstable")]
56        {
57            app = app
58                .subcommand(SeaplaneFormationConfiguration::command())
59                .subcommand(SeaplaneFormationContainerStatistics::command())
60                .subcommand(SeaplaneFormationLoadBalance::command())
61                .subcommand(SeaplaneFormationTemplate::command())
62        }
63
64        app
65    }
66}
67
68impl CliCommand for SeaplaneFormation {
69    fn next_subcmd<'a>(
70        &self,
71        matches: &'a ArgMatches,
72    ) -> Option<(Box<dyn CliCommand>, &'a ArgMatches)> {
73        match &matches.subcommand() {
74            Some(("plan", m)) => Some((Box::new(SeaplaneFormationPlan), m)),
75            Some(("delete", m)) => Some((Box::new(SeaplaneFormationDelete), m)),
76            Some(("fetch-remote", m)) => Some((Box::new(SeaplaneFormationFetch), m)),
77            Some(("land", m)) => Some((Box::new(SeaplaneFormationLand), m)),
78            Some(("launch", m)) => Some((Box::new(SeaplaneFormationLaunch), m)),
79            Some(("list", m)) => Some((Box::new(SeaplaneFormationList), m)),
80            Some(("status", m)) => Some((Box::new(SeaplaneFormationStatus), m)),
81            #[cfg(feature = "unstable")]
82            Some(("configuration", m)) => Some((Box::new(SeaplaneFormationConfiguration), m)),
83            #[cfg(feature = "unstable")]
84            Some(("container-statistics", m)) => {
85                Some((Box::new(SeaplaneFormationContainerStatistics), m))
86            }
87            #[cfg(feature = "unstable")]
88            Some(("load-balance", m)) => Some((Box::new(SeaplaneFormationLoadBalance), m)),
89            #[cfg(feature = "unstable")]
90            Some(("template", m)) => Some((Box::new(SeaplaneFormationTemplate), m)),
91            _ => None,
92        }
93    }
94
95    fn update_ctx(&self, _matches: &ArgMatches, _ctx: &mut Ctx) -> Result<()> { Ok(()) }
96}