-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.rs
89 lines (71 loc) · 1.72 KB
/
cli.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
use clap::{Parser, Subcommand, command};
use std::path::PathBuf;
#[derive(Debug, Parser)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
/// Alternative configuration file path
#[arg(long, value_name = "PATH")]
pub config: Option<PathBuf>,
/// Enable debug logging
#[arg(long)]
pub debug: bool,
#[command(subcommand)]
pub command: Option<Command>,
}
#[derive(Debug, Subcommand)]
pub enum Command {
/// Service management
Service {
#[command(subcommand)]
command: ServiceCommand,
},
/// Database management
Database {
#[command(subcommand)]
command: DatabaseCommand,
},
/// Test connection to a PWMP server
Test {
/// Host to connect to
host: String,
/// MAC address to authenticate with
mac: String,
/// Alternative port to use
port: Option<u16>,
},
}
#[derive(Debug, Subcommand, Clone, Copy)]
pub enum ServiceCommand {
/// Start the service
Start,
/// Stop the service
Stop,
/// Enable
Enable,
/// Disable
Disable,
/// Install as service
Install,
/// Uninstall service
Uninstall,
/// Check the status of the service
Status,
/// Reinstall service
Reinstall,
}
#[derive(Debug, Subcommand, Clone, Copy)]
pub enum DatabaseCommand {
/// Test connection to the database
Test,
/// Initialize the database
Init,
/// Completely ERASE ALL DATA from the database (*UNRECOVERABLE*)
Erase {
/// Only remove rows, not tables
#[arg(long)]
content_only: bool,
/// Keep configured devices and their settings
#[arg(long)]
keep_devices: bool,
},
}