arachnid_cli/cli/
cmd.rs

1/*
2    Appellation: ops <module>
3    Created At: 2026.01.10:15:56:39
4    Contrib: @FL03
5*/
6//! the subcommands for the CLI application
7#[doc(inline)]
8pub use self::connect::*;
9
10mod connect;
11
12use crate::Context;
13
14#[derive(
15    Clone,
16    Debug,
17    Eq,
18    Hash,
19    Ord,
20    PartialEq,
21    PartialOrd,
22    clap::Subcommand,
23    serde::Deserialize,
24    serde::Serialize,
25    strum::EnumIs,
26    strum::VariantNames,
27)]
28#[repr(C)]
29pub enum Command {
30    Connect(ConnectCmd),
31}
32
33impl Command {
34    /// initialize a new [`Connect`](Command::Connect) command variant using the given value
35    pub const fn connect(cmd: ConnectCmd) -> Self {
36        Self::Connect(cmd)
37    }
38    /// returns the name of the command variant
39    pub fn name(&self) -> &str {
40        match self {
41            Self::Connect(_) => "connect",
42        }
43    }
44    /// handle the command using the given context
45    #[tracing::instrument(skip_all)]
46    pub async fn handle(&self, ctx: &mut Context) -> anyhow::Result<()> {
47        match self {
48            Self::Connect(cmd) => cmd.handle(ctx).await,
49        }
50    }
51}