Skip to content

Commit f12e6b9

Browse files
Refactor CLI code for improved readability
1 parent 27ee16d commit f12e6b9

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

src/app/cli.rs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@ use crate::core::config::load_config;
22
use crate::core::engine::run_pipeline_cli;
33
use crate::core::report::render_report;
44
use crate::core::state::{get_findings_internal, load_session_from_db, AppState};
5-
use crate::core::tools::{tool_statuses};
5+
use crate::core::tools::tool_statuses;
66
use crate::core::types::ScanRequest;
77
use anyhow::Result;
8-
use std::sync::Arc;
98
use std::fs;
9+
use std::sync::Arc;
1010

1111
fn cli_usage() -> &'static str {
1212
"torot 4.0.0
@@ -67,11 +67,21 @@ pub fn run() -> Result<bool> {
6767
async fn cmd_tools(state: &Arc<AppState>) -> Result<()> {
6868
let config = load_config(state)?;
6969
let statuses = tool_statuses(&config);
70-
println!("{:<12} {:<9} {:<20} {}", "Tool", "Status", "Version", "Binary");
70+
println!(
71+
"{:<12} {:<9} {:<20} {}",
72+
"Tool", "Status", "Version", "Binary"
73+
);
7174
println!("{}", "-".repeat(60));
7275
for tool in statuses {
73-
let status = if tool.installed { "installed" } else { "missing" };
74-
println!("{:<12} {:<9} {:<20} {}", tool.name, status, tool.version, tool.binary);
76+
let status = if tool.installed {
77+
"installed"
78+
} else {
79+
"missing"
80+
};
81+
println!(
82+
"{:<12} {:<9} {:<20} {}",
83+
tool.name, status, tool.version, tool.binary
84+
);
7585
}
7686
Ok(())
7787
}
@@ -96,7 +106,8 @@ async fn cmd_scan(args: &[String], state: &Arc<AppState>) -> Result<()> {
96106
}
97107

98108
async fn cmd_report(args: &[String], state: &Arc<AppState>) -> Result<()> {
99-
let session_id = cli_arg(args, "--session").ok_or_else(|| anyhow::anyhow!("Missing --session"))?;
109+
let session_id =
110+
cli_arg(args, "--session").ok_or_else(|| anyhow::anyhow!("Missing --session"))?;
100111
let findings = get_findings_internal(&session_id, state);
101112
let session = load_session_from_db(state, &session_id)?
102113
.ok_or_else(|| anyhow::anyhow!("Session not found."))?;

0 commit comments

Comments
 (0)