arachnid_cli/cli/cmd/
connect.rs

1/*
2    Appellation: connect <module>
3    Created At: 2026.01.10:15:53:44
4    Contrib: @FL03
5*/
6
7#[derive(
8    Clone,
9    Debug,
10    Default,
11    Eq,
12    Hash,
13    Ord,
14    PartialEq,
15    PartialOrd,
16    clap::Parser,
17    serde::Deserialize,
18    serde::Serialize,
19)]
20pub struct ConnectCmd {
21    #[clap(subcommand)]
22    pub args: Option<ConnectOpts>,
23    #[clap(long, short = 'H')]
24    pub host: Option<String>,
25    #[clap(long, short)]
26    pub port: Option<u16>,
27    #[clap(long, short)]
28    pub workdir: Option<String>,
29}
30
31#[derive(
32    Clone,
33    Debug,
34    Eq,
35    Hash,
36    Ord,
37    PartialEq,
38    PartialOrd,
39    clap::Subcommand,
40    serde::Deserialize,
41    serde::Serialize,
42)]
43pub enum ConnectOpts {
44    Run {
45        #[clap(long, short)]
46        prefix: Option<String>,
47    },
48}
49
50/*
51 ************* Implementations *************
52*/
53
54impl ConnectCmd {
55    pub fn new() -> Self {
56        clap::Parser::parse()
57    }
58    /// returns a reference to the optional command arguments
59    pub fn args(&self) -> Option<&ConnectOpts> {
60        self.args.as_ref()
61    }
62    /// returns a reference to the configured host
63    pub fn host(&self) -> Option<&str> {
64        self.host.as_deref()
65    }
66    /// returns the port
67    pub fn port(&self) -> Option<u16> {
68        self.port
69    }
70    /// handle the current command with the given context
71    #[tracing::instrument(skip_all, target = "cli")]
72    pub async fn handle(&self, _ctx: &mut crate::Context) -> anyhow::Result<()> {
73        tracing::info!("Handling 'connect' command with args: {:?}", self);
74        Ok(())
75    }
76}