diff --git a/cli/src/command.rs b/cli/src/command.rs index 7f17a4be..23e012be 100644 --- a/cli/src/command.rs +++ b/cli/src/command.rs @@ -61,6 +61,13 @@ fn check_password(password: &Option, cipher_args: &CipherAlgorithmArgs) } } -trait Command { +pub trait Command { fn execute(self) -> io::Result<()>; } + +impl Command for Cli { + #[inline] + fn execute(self) -> io::Result<()> { + entry(self) + } +} diff --git a/cli/src/main.rs b/cli/src/main.rs index c277a434..d06212ec 100644 --- a/cli/src/main.rs +++ b/cli/src/main.rs @@ -5,13 +5,14 @@ mod ext; mod utils; use clap::Parser; +use command::Command; use log::Level; use std::io; fn main() -> io::Result<()> { - let args = cli::Cli::parse(); - init_logger(args.verbosity.log_level_filter())?; - command::entry(args) + let cli = cli::Cli::parse(); + init_logger(cli.verbosity.log_level_filter())?; + cli.execute() } fn init_logger(level: log::LevelFilter) -> io::Result<()> {