-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathcommands.rs
More file actions
114 lines (105 loc) · 3.7 KB
/
Copy pathcommands.rs
File metadata and controls
114 lines (105 loc) · 3.7 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//! CLI Command Definitions
//!
//! This module defines the command-line interface structure and available commands
//! for the Torrust Tracker Deployer CLI application.
use clap::Subcommand;
use std::path::PathBuf;
/// Available CLI commands
///
/// This enum defines all the subcommands available in the CLI application.
/// Each variant represents a specific operation that can be performed.
#[derive(Subcommand, Debug)]
pub enum Commands {
/// Create operations (environment creation or template generation)
///
/// This command provides subcommands for creating environments and generating
/// configuration templates.
Create {
#[command(subcommand)]
action: CreateAction,
},
/// Destroy an existing deployment environment
///
/// This command will tear down all infrastructure associated with the
/// specified environment, including virtual machines, networks, and
/// persistent data. This operation is irreversible.
Destroy {
/// Name of the environment to destroy
///
/// The environment name must be a valid identifier that was previously
/// created through the provision command.
environment: String,
},
// Future commands will be added here:
//
// /// Provision a new deployment environment
// Provision {
// /// Name of the environment to create
// environment: String,
// /// Infrastructure provider to use (lxd, multipass, etc.)
// #[arg(long, default_value = "lxd")]
// provider: String,
// },
//
// /// Configure an existing deployment environment
// Configure {
// /// Name of the environment to configure
// environment: String,
// },
//
// /// Create a new release of the deployed application
// Release {
// /// Name of the environment for the release
// environment: String,
// /// Version tag for the release
// version: String,
// },
}
/// Actions available for the create command
#[derive(Debug, Subcommand)]
pub enum CreateAction {
/// Create environment from configuration file
///
/// This subcommand creates a new deployment environment based on a
/// configuration file. The configuration file specifies the environment
/// name, SSH credentials, and other settings required for creation.
Environment {
/// Path to the environment configuration file
///
/// The configuration file must be in JSON format and contain all
/// required fields for environment creation.
#[arg(long, short = 'f', value_name = "FILE")]
env_file: PathBuf,
},
/// Generate template configuration file
///
/// This subcommand generates a JSON configuration template file with
/// placeholder values. Edit the template to provide your actual
/// configuration values, then use 'create environment' to create
/// the environment.
Template {
/// Output path for the template file (optional)
///
/// If not provided, creates environment-template.json in the
/// current working directory. Parent directories will be created
/// automatically if they don't exist.
#[arg(value_name = "PATH")]
output_path: Option<PathBuf>,
},
}
impl CreateAction {
/// Get the default template output path
#[must_use]
pub fn default_template_path() -> PathBuf {
PathBuf::from("environment-template.json")
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_should_use_default_template_path() {
let default_path = CreateAction::default_template_path();
assert_eq!(default_path, PathBuf::from("environment-template.json"));
}
}