-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhelp.rs
More file actions
130 lines (125 loc) · 4.9 KB
/
help.rs
File metadata and controls
130 lines (125 loc) · 4.9 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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
//! Help and Usage Information Module
//!
//! This module provides help and usage information for the Torrust Tracker Deployer
//! application. It contains functions to display helpful information to users
//! when they need guidance on how to use the application.
//!
//! ## Design Principles
//!
//! - **Independent**: No dependencies on presentation layer or CLI structures
//! - **User-Focused**: Clear, actionable guidance for users
//! - **Comprehensive**: Covers getting started, examples, and next steps
/// Display helpful information to the user when no command is provided
///
/// This function shows getting started information, usage examples, and
/// helpful links when the user runs the application without any subcommands.
/// It provides a friendly introduction to the application and guides users
/// toward productive next steps.
///
/// # Output
///
/// Prints directly to stdout with formatted, user-friendly content including:
/// - Application overview and purpose
/// - Getting started instructions
/// - Testing guidance
/// - Documentation references
/// - Next steps for users
///
/// # Example
///
/// ```rust
/// use torrust_tracker_deployer_lib::bootstrap::help;
///
/// // Display help when user runs app without arguments
/// help::display_getting_started();
/// ```
pub fn display_getting_started() {
println!("🏗️ Torrust Tracker Deployer");
println!("=========================");
println!();
println!("This repository provides automated deployment infrastructure for Torrust tracker projects.");
println!("The infrastructure includes VM provisioning with OpenTofu and configuration");
println!("management with Ansible playbooks.");
println!();
println!("📋 Getting Started:");
println!(" Please follow the instructions in the README.md file to:");
println!(" 1. Set up the required dependencies (OpenTofu, Ansible, LXD)");
println!(" 2. Provision the deployment infrastructure");
println!(" 3. Deploy and configure the services");
println!();
println!("🧪 Running E2E Tests:");
println!(" Use the e2e tests binaries to run end-to-end tests:");
println!(" cargo e2e-provision && cargo e2e-config");
println!();
println!("📖 For detailed instructions, see: README.md");
println!();
println!("💡 To see available commands, run: torrust-tracker-deployer --help");
}
/// Display troubleshooting information for common issues
///
/// This function provides guidance for common problems users might encounter
/// when setting up or using the Torrust Tracker Deployer.
///
/// # Output
///
/// Prints troubleshooting guidance to stdout including:
/// - Common setup issues and solutions
/// - Dependency verification steps
/// - Configuration validation tips
/// - Where to get additional help
///
/// # Example
///
/// ```rust
/// use torrust_tracker_deployer_lib::bootstrap::help;
///
/// // Display troubleshooting info when user encounters issues
/// help::display_troubleshooting();
/// ```
pub fn display_troubleshooting() {
println!("🔧 Troubleshooting Guide");
println!("=======================");
println!();
println!("Common issues and solutions:");
println!();
println!("1. Dependencies not found:");
println!(" - Ensure OpenTofu is installed and in PATH");
println!(" - Verify Ansible is installed and accessible");
println!(" - Check that LXD is properly configured");
println!();
println!("2. Permission errors:");
println!(" - Add your user to the lxd group: sudo usermod -aG lxd $USER");
println!(" - Log out and log back in to apply group changes");
println!(" - Verify permissions with: groups");
println!();
println!("3. Network connectivity issues:");
println!(" - Check internet connectivity for image downloads");
println!(" - Verify LXD daemon is running: lxd --version");
println!(" - Test basic LXD functionality: lxc list");
println!();
println!("4. Configuration problems:");
println!(" - Validate YAML/JSON syntax in configuration files");
println!(" - Check that environment names follow naming conventions");
println!(" - Ensure SSH keys are properly configured");
println!();
println!("📖 For more help:");
println!(" - Check the docs/ directory for detailed guides");
println!(" - Review the README.md for setup instructions");
println!(" - Open an issue on GitHub for additional support");
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_should_display_getting_started_without_panicking() {
// Test that the function runs without panicking
// We can't easily test stdout content in unit tests,
// but we can ensure the function doesn't crash
display_getting_started();
}
#[test]
fn it_should_display_troubleshooting_without_panicking() {
// Test that the function runs without panicking
display_troubleshooting();
}
}