seaplane_cli/cli/cmds/
restrict.rs

1pub mod common;
2mod delete;
3mod get;
4mod list;
5mod set;
6
7use clap::{ArgMatches, Command};
8
9pub use self::{
10    common::SeaplaneRestrictCommonArgMatches,
11    delete::SeaplaneRestrictDelete,
12    get::SeaplaneRestrictGet,
13    list::{SeaplaneRestrictList, SeaplaneRestrictListArgMatches},
14    set::{SeaplaneRestrictSet, SeaplaneRestrictSetArgMatches},
15};
16use crate::cli::CliCommand;
17
18#[derive(Copy, Clone, Debug)]
19pub struct SeaplaneRestrict;
20
21impl SeaplaneRestrict {
22    pub fn command() -> Command {
23        Command::new("restrict")
24            .about("Restrict the placement of data for Global Data Coordination API")
25            .subcommand_required(true)
26            .arg_required_else_help(true)
27            .subcommand(SeaplaneRestrictGet::command())
28            .subcommand(SeaplaneRestrictList::command())
29            .subcommand(SeaplaneRestrictSet::command())
30            .subcommand(SeaplaneRestrictDelete::command())
31    }
32}
33
34impl CliCommand for SeaplaneRestrict {
35    fn next_subcmd<'a>(
36        &self,
37        matches: &'a ArgMatches,
38    ) -> Option<(Box<dyn CliCommand>, &'a ArgMatches)> {
39        match &matches.subcommand() {
40            Some(("get", m)) => Some((Box::new(SeaplaneRestrictGet), m)),
41            Some(("list", m)) => Some((Box::new(SeaplaneRestrictList), m)),
42            Some(("set", m)) => Some((Box::new(SeaplaneRestrictSet), m)),
43            Some(("delete", m)) => Some((Box::new(SeaplaneRestrictDelete), m)),
44            _ => None,
45        }
46    }
47}