1use clap::Parser;
2use eyre::Result;
3use foundry_cli::utils;
4use foundry_common::shell;
5use soldeer_commands::{Command, Verbosity};
6
7#[derive(Clone, Debug, Parser)]
10#[command(
11 override_usage = "Native Solidity Package Manager, run `forge soldeer [COMMAND] --help` for more details"
12)]
13pub struct SoldeerArgs {
14 #[command(subcommand)]
17 command: Command,
18}
19
20impl SoldeerArgs {
21 pub async fn run(self) -> Result<()> {
22 if std::env::var_os("RUST_LOG").is_none() {
25 let level = match shell::verbosity() {
26 0 => "error",
27 1 => "warn",
28 2 => "info",
29 3 => "debug",
30 _ => "trace",
31 };
32 utils::update_tracing_filter(level);
33 }
34
35 let verbosity = Verbosity::new(shell::verbosity(), if shell::is_quiet() { 1 } else { 0 });
36 match soldeer_commands::run(self.command, verbosity).await {
37 Ok(_) => Ok(()),
38 Err(err) => Err(eyre::eyre!("Failed to run soldeer: {err}")),
39 }
40 }
41}
42
43#[cfg(test)]
44mod tests {
45 use soldeer_commands::{Command, Verbosity, commands::Version};
46
47 #[tokio::test]
48 async fn test_soldeer_version() {
49 let command = Command::Version(Version::default());
50 assert!(soldeer_commands::run(command, Verbosity::new(0, 1)).await.is_ok());
51 }
52}