Skip to content

Commit 9218a07

Browse files
style: apply rustfmt to improve code formatting and style
1 parent 25249ff commit 9218a07

38 files changed

+2050
-1604
lines changed

src/clparse.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -500,5 +500,6 @@ pub fn parse_command_line() -> ArgMatches<'static> {
500500
.help("Enable transaction history (increases storage requirements)")
501501
)
502502
)
503+
)
503504
.get_matches()
504505
}

src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! OSVM CLI Library
2-
//!
2+
//!
33
//! This library provides the core functionality for the OSVM CLI.
44
//! It includes utilities for managing SVMs, nodes, and SSH deployments.
55
//!
@@ -18,6 +18,6 @@
1818
//! - `clparse`: Command-line parsing and argument definitions
1919
//! - `main`: Main entry point and command handlers
2020
21-
pub mod utils;
2221
pub mod clparse;
23-
pub mod prelude;
22+
pub mod prelude;
23+
pub mod utils;

src/main.rs

Lines changed: 164 additions & 110 deletions
Large diffs are not rendered by default.

src/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ pub use crate::utils::dashboard;
1414
// Example command utilities
1515
pub use crate::utils::examples;
1616
// Color formatting utilities
17-
pub use crate::utils::color;
17+
pub use crate::utils::color;

src/utils/color.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! Color utility functions for consistent CLI output formatting
2-
//!
2+
//!
33
//! This module provides standardized colors and formatting for different types of CLI output
44
//! such as success messages, warnings, errors, and information. It centralizes color schemes
55
//! to ensure consistent user experience across all commands.
@@ -72,7 +72,11 @@ pub fn node_status(status: &str) -> colored::ColoredString {
7272
}
7373

7474
/// Format numeric value with appropriate color based on threshold
75-
pub fn numeric_value(value: f64, warning_threshold: f64, error_threshold: f64) -> colored::ColoredString {
75+
pub fn numeric_value(
76+
value: f64,
77+
warning_threshold: f64,
78+
error_threshold: f64,
79+
) -> colored::ColoredString {
7680
if value >= error_threshold {
7781
format!("{:.1}", value).red()
7882
} else if value >= warning_threshold {
@@ -89,7 +93,8 @@ pub fn table_header(text: &str) -> colored::ColoredString {
8993

9094
/// Format separator line (bright black)
9195
pub fn separator() -> colored::ColoredString {
92-
"---------------------------------------------------------------------------------".bright_black()
96+
"---------------------------------------------------------------------------------"
97+
.bright_black()
9398
}
9499

95100
/// Format text with custom color
@@ -110,4 +115,4 @@ pub fn italic(text: &str) -> colored::ColoredString {
110115
/// Format text as code/monospace
111116
pub fn code(text: &str) -> colored::ColoredString {
112117
text.white().on_bright_black()
113-
}
118+
}

src/utils/dashboard.rs

Lines changed: 59 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ impl Default for DashboardManager {
5555

5656
impl DashboardManager {
5757
/// Create a new dashboard manager
58-
///
58+
///
5959
/// # Arguments
6060
/// * `output_dir` - Directory to save dashboard files
6161
/// * `verbosity` - Verbosity level (0-3)
62-
///
62+
///
6363
/// # Returns
6464
/// * `DashboardManager` - Dashboard manager
6565
pub fn new(output_dir: &str, verbosity: u8) -> Self {
@@ -69,140 +69,148 @@ impl DashboardManager {
6969
verbosity,
7070
}
7171
}
72-
72+
7373
/// Set dashboard title
74-
///
74+
///
7575
/// # Arguments
7676
/// * `title` - Dashboard title
77-
///
77+
///
7878
/// # Returns
7979
/// * `&mut Self` - Self reference for method chaining
8080
pub fn with_title(&mut self, title: &str) -> &mut Self {
8181
self.title = title.to_string();
8282
self
8383
}
84-
84+
8585
/// Set verbosity level
86-
///
86+
///
8787
/// # Arguments
8888
/// * `verbosity` - Verbosity level (0-3)
89-
///
89+
///
9090
/// # Returns
9191
/// * `&mut Self` - Self reference for method chaining
9292
pub fn with_verbosity(&mut self, verbosity: u8) -> &mut Self {
9393
self.verbosity = verbosity;
9494
self
9595
}
96-
96+
9797
/// Generate and save dashboard HTML
98-
///
98+
///
9999
/// # Arguments
100100
/// * `nodes` - List of node information
101-
///
101+
///
102102
/// # Returns
103103
/// * `Result<String, Box<dyn Error>>` - Path to the dashboard file
104104
pub fn generate_dashboard(&self, nodes: &[NodeInfo]) -> Result<String, Box<dyn Error>> {
105105
// Ensure output directory exists
106106
fs::create_dir_all(&self.output_dir)?;
107-
107+
108108
// Generate HTML content
109109
// Pass verbosity level to the dashboard generator
110110
let html_content = generate_monitoring_dashboard(nodes, self.verbosity);
111-
112-
111+
113112
// Create output file path
114113
let file_path = format!("{}/osvm_dashboard.html", self.output_dir);
115-
114+
116115
// Write HTML to file
117116
fs::write(&file_path, html_content)?;
118-
117+
119118
Ok(file_path)
120119
}
121-
120+
122121
/// Open dashboard in default browser
123-
///
122+
///
124123
/// # Arguments
125124
/// * `file_path` - Path to the dashboard HTML file
126-
///
125+
///
127126
/// # Returns
128127
/// * `Result<(), Box<dyn Error>>` - Result
129128
pub fn open_in_browser(&self, file_path: &str) -> Result<(), Box<dyn Error>> {
130129
// Convert to absolute path if needed
131130
let path = Path::new(file_path);
132-
131+
133132
// Get file URL
134133
let file_url = if path.is_absolute() {
135134
format!("file://{}", path.display())
136135
} else {
137136
let abs_path = fs::canonicalize(path)?;
138137
format!("file://{}", abs_path.display())
139138
};
140-
139+
141140
// Determine the platform and open browser accordingly
142141
#[cfg(target_os = "windows")]
143142
{
144143
Command::new("cmd")
145144
.args(&["/c", "start", "", &file_url])
146145
.spawn()
147-
.map_err(|e| Box::new(DashboardError::BrowserError(e.to_string())) as Box<dyn Error>)?;
146+
.map_err(|e| {
147+
Box::new(DashboardError::BrowserError(e.to_string())) as Box<dyn Error>
148+
})?;
148149
}
149-
150+
150151
#[cfg(target_os = "macos")]
151152
{
152-
Command::new("open")
153-
.arg(&file_url)
154-
.spawn()
155-
.map_err(|e| Box::new(DashboardError::BrowserError(e.to_string())) as Box<dyn Error>)?;
153+
Command::new("open").arg(&file_url).spawn().map_err(|e| {
154+
Box::new(DashboardError::BrowserError(e.to_string())) as Box<dyn Error>
155+
})?;
156156
}
157-
157+
158158
#[cfg(target_os = "linux")]
159159
{
160160
Command::new("xdg-open")
161161
.arg(&file_url)
162162
.spawn()
163-
.map_err(|e| Box::new(DashboardError::BrowserError(e.to_string())) as Box<dyn Error>)?;
163+
.map_err(|e| {
164+
Box::new(DashboardError::BrowserError(e.to_string())) as Box<dyn Error>
165+
})?;
164166
}
165-
167+
166168
Ok(())
167169
}
168-
170+
169171
/// Generate dashboard and open in browser
170-
///
172+
///
171173
/// # Arguments
172174
/// * `nodes` - List of node information
173-
///
175+
///
174176
/// # Returns
175177
/// * `Result<(), Box<dyn Error>>` - Result
176178
pub fn generate_and_open(&self, nodes: &[NodeInfo]) -> Result<(), Box<dyn Error>> {
177179
let file_path = self.generate_dashboard(nodes)?;
178180
self.open_in_browser(&file_path)?;
179-
181+
180182
Ok(())
181183
}
182-
184+
183185
/// Create a real-time dashboard server (this would require an actual implementation)
184-
///
186+
///
185187
/// # Arguments
186188
/// * `port` - Port to run the dashboard server on
187-
///
189+
///
188190
/// # Returns
189191
/// * `Result<(), Box<dyn Error>>` - Result
190192
pub fn run_dashboard_server(&self, port: u16, verbosity: u8) -> Result<(), Box<dyn Error>> {
191193
// This would normally start a web server that provides real-time updates
192194
// For this prototype, we'll just print a message with detail based on verbosity
193-
println!("Dashboard server would be running on http://localhost:{}", port);
194-
195+
println!(
196+
"Dashboard server would be running on http://localhost:{}",
197+
port
198+
);
199+
195200
// Show additional details based on verbosity level
196201
match verbosity {
197202
0 => Ok(()), // Minimal output
198203
1 => {
199204
println!("(Real implementation would start an actual web server)");
200205
Ok(())
201-
},
206+
}
202207
2 => {
203-
println!("Monitoring {} nodes with refresh rate of {} seconds", "[node_count]", 5);
208+
println!(
209+
"Monitoring {} nodes with refresh rate of {} seconds",
210+
"[node_count]", 5
211+
);
204212
Ok(())
205-
},
213+
}
206214
_ => {
207215
println!("Starting server with detailed debug logging enabled for development");
208216
Ok(())
@@ -212,11 +220,11 @@ impl DashboardManager {
212220
}
213221

214222
/// Save a quick dashboard to the current directory and open it
215-
///
223+
///
216224
/// # Arguments
217225
/// * `nodes` - List of node information
218226
/// * `verbosity` - Verbosity level (0-3)
219-
///
227+
///
220228
/// # Returns
221229
/// * `Result<(), Box<dyn Error>>` - Result
222230
pub fn quick_dashboard(nodes: &[NodeInfo], verbosity: u8) -> Result<(), Box<dyn Error>> {
@@ -226,13 +234,16 @@ pub fn quick_dashboard(nodes: &[NodeInfo], verbosity: u8) -> Result<(), Box<dyn
226234
}
227235

228236
/// Run the dashboard with the given RPC client and commitment config
229-
///
237+
///
230238
/// # Arguments
231239
/// * `client` - RPC client
232240
/// * `commitment_config` - Commitment config
233-
///
241+
///
234242
/// # Returns
235243
/// * `Result<(), Box<dyn Error>>` - Result
236-
pub fn run_dashboard(client: &RpcClient, commitment_config: CommitmentConfig) -> Result<(), Box<dyn Error>> {
244+
pub fn run_dashboard(
245+
client: &RpcClient,
246+
commitment_config: CommitmentConfig,
247+
) -> Result<(), Box<dyn Error>> {
237248
crate::utils::nodes::run_dashboard(client, commitment_config, 1)
238-
}
249+
}

0 commit comments

Comments
 (0)