Skip to content

Commit

Permalink
♻️ impl Command for Cli
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanTsune committed Nov 19, 2024
1 parent 15eaf5b commit 079112a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
9 changes: 8 additions & 1 deletion cli/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ fn check_password(password: &Option<String>, 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)
}
}
7 changes: 4 additions & 3 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<()> {
Expand Down

0 comments on commit 079112a

Please sign in to comment.