Skip to content

Commit 385efa2

Browse files
Copilotjosecelano
andcommitted
refactor: [#115] address code review comments
Co-authored-by: josecelano <58816+josecelano@users.noreply.github.com>
1 parent e4140a0 commit 385efa2

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

packages/dependency-installer/src/bin/dependency-installer.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
6868
let cli = Cli::parse();
6969

7070
// Initialize tracing based on verbose flag
71+
// Must set environment variable before calling init_tracing()
7172
if cli.verbose {
7273
std::env::set_var("RUST_LOG", "debug");
7374
}
@@ -114,7 +115,7 @@ fn check_all_tools(manager: &DependencyManager) -> Result<(), Box<dyn std::error
114115
results.len()
115116
);
116117
error!("{}", msg);
117-
println!("{msg}");
118+
eprintln!("{msg}");
118119
Err(msg.into())
119120
} else {
120121
info!("All dependencies are installed");
@@ -142,7 +143,7 @@ fn check_specific_tool(
142143
} else {
143144
let msg = format!("{}: not installed", detector.name());
144145
error!(tool = detector.name(), "Tool is not installed");
145-
println!("✗ {msg}");
146+
eprintln!("✗ {msg}");
146147
Err(msg.into())
147148
}
148149
}
@@ -170,8 +171,12 @@ fn parse_tool_name(name: &str) -> Result<Dependency, String> {
170171
"opentofu" | "tofu" => Ok(Dependency::OpenTofu),
171172
"ansible" => Ok(Dependency::Ansible),
172173
"lxd" => Ok(Dependency::Lxd),
173-
_ => Err(format!(
174-
"Unknown tool: {name}. Available: cargo-machete, opentofu, ansible, lxd"
175-
)),
174+
_ => {
175+
// List of available tools - should be kept in sync with the match arms above
176+
const AVAILABLE_TOOLS: &str = "cargo-machete, opentofu, ansible, lxd";
177+
Err(format!(
178+
"Unknown tool: {name}. Available: {AVAILABLE_TOOLS}"
179+
))
180+
}
176181
}
177182
}

0 commit comments

Comments
 (0)