zinit_client/cli/
args.rs

1//! CLI argument definitions using clap
2
3use clap::{Parser, Subcommand};
4
5#[derive(Parser, Debug)]
6#[command(name = "zinit")]
7#[command(author = "ThreeFold Tech")]
8#[command(version)]
9#[command(about = "Zinit process supervisor client", long_about = None)]
10pub struct Args {
11    /// Server address (default: 127.0.0.1:9123)
12    #[arg(short, long, default_value = "127.0.0.1:9123")]
13    pub server: String,
14
15    /// Read script from stdin
16    #[arg(short = 'i', long = "stdin")]
17    pub stdin: bool,
18
19    /// Execute inline script
20    #[arg(short = 'c', long = "command")]
21    pub inline_script: Option<String>,
22
23    #[command(subcommand)]
24    pub command: Option<Command>,
25
26    /// Run a Rhai script file
27    #[arg(value_name = "SCRIPT")]
28    pub script: Option<String>,
29}
30
31#[derive(Subcommand, Debug)]
32pub enum Command {
33    /// Server management commands
34    Server {
35        #[command(subcommand)]
36        action: ServerAction,
37    },
38
39    /// List all services
40    List,
41
42    /// Get status of a service
43    Status {
44        /// Service name
45        name: String,
46    },
47
48    /// Start a service
49    Start {
50        /// Service name
51        name: String,
52    },
53
54    /// Stop a service
55    Stop {
56        /// Service name
57        name: String,
58    },
59
60    /// Restart a service
61    Restart {
62        /// Service name
63        name: String,
64    },
65
66    /// Delete a service
67    Delete {
68        /// Service name
69        name: String,
70    },
71
72    /// Send signal to a service
73    Kill {
74        /// Service name
75        name: String,
76        /// Signal name (default: SIGTERM)
77        #[arg(default_value = "SIGTERM")]
78        signal: String,
79    },
80
81    /// Get service resource usage statistics
82    Stats {
83        /// Service name
84        name: String,
85    },
86
87    /// View logs
88    Logs {
89        /// Service name (optional, shows all if not specified)
90        service: Option<String>,
91        /// Follow logs (not yet implemented)
92        #[arg(short, long)]
93        follow: bool,
94        /// Number of lines to show
95        #[arg(short = 'n', long, default_value = "50")]
96        lines: u32,
97    },
98
99    /// Interactive REPL
100    Repl,
101
102    /// Full-screen TUI
103    Tui,
104
105    /// Ping the server
106    Ping,
107}
108
109#[derive(Subcommand, Debug)]
110pub enum ServerAction {
111    /// Start the server (foreground)
112    Start {
113        /// Run in background
114        #[arg(short = 'b', long)]
115        background: bool,
116        /// TCP port to listen on
117        #[arg(short, long)]
118        port: Option<u16>,
119    },
120    /// Stop the server
121    Stop,
122    /// Restart the server
123    Restart,
124}