Skip to main content

mecha10_cli/infrastructure/
types.rs

1//! Infrastructure types
2
3#![allow(dead_code)]
4
5use mecha10_core::enum_str_method;
6
7#[derive(Debug, Clone)]
8pub struct InfrastructureArgs {
9    pub action: InfrastructureAction,
10    pub services: Vec<String>,
11}
12
13#[derive(Debug, Clone, PartialEq)]
14pub enum InfrastructureAction {
15    Start,
16    Stop,
17    Restart,
18    Status,
19    #[allow(dead_code)]
20    Logs,
21}
22
23impl InfrastructureAction {
24    #[allow(dead_code)]
25    pub fn parse(s: &str) -> Option<Self> {
26        match s {
27            "start" => Some(Self::Start),
28            "stop" => Some(Self::Stop),
29            "restart" => Some(Self::Restart),
30            "status" => Some(Self::Status),
31            "logs" => Some(Self::Logs),
32            _ => None,
33        }
34    }
35}
36
37enum_str_method!(
38    #[allow(dead_code)]
39    pub fn as_str(InfrastructureAction) -> &str {
40        Start => "start",
41        Stop => "stop",
42        Restart => "restart",
43        Status => "status",
44        Logs => "logs",
45    }
46);