Extract cmd dispatch code from src/delete/main.rs to delete::cli module.

Changes:
- Introduce cli::dispatch_cmd() function which just delegate to delete function.
This commit is contained in:
Zeke Fast
2025-05-03 11:44:05 +02:00
parent abeafbe3d4
commit b296157c08
2 changed files with 10 additions and 3 deletions

View File

@@ -1,5 +1,7 @@
use structopt::StructOpt;
use std::path::PathBuf;
use hagrid_database::KeyDatabase;
use crate::delete;
#[derive(Debug, StructOpt)]
#[structopt(
@@ -23,3 +25,7 @@ pub(crate) struct Opt {
#[structopt(long = "all")]
pub(crate) all: bool,
}
pub(crate) fn dispatch_cmd(opts: &Opt, db: &KeyDatabase) -> anyhow::Result<()> {
delete(&db, &opts.query.parse()?, opts.all_bindings, opts.all)
}

View File

@@ -20,9 +20,10 @@ fn main() {
}
fn real_main() -> anyhow::Result<()> {
let opt = cli::Opt::from_args();
let db = KeyDatabase::new_file(opt.base.canonicalize()?)?;
delete(&db, &opt.query.parse()?, opt.all_bindings, opt.all)
let opt = &cli::Opt::from_args();
let db = &KeyDatabase::new_file(opt.base.canonicalize()?)?;
cli::dispatch_cmd(opt, db)
}
fn delete(