refactor: update function parameters to use references where appropriate
This commit is contained in:
committed by
Andrew Phillips (aider)
parent
d1edd20845
commit
dd8f828ed3
16
src/main.rs
16
src/main.rs
@@ -279,27 +279,27 @@ fn main() -> Result<(), Error> {
|
|||||||
|
|
||||||
match mode {
|
match mode {
|
||||||
KeepModes::Save => {
|
KeepModes::Save => {
|
||||||
crate::modes::save::mode_save(&mut cmd, args, ids, tags, &mut conn, data_path)?
|
crate::modes::save::mode_save(&mut cmd, &args, ids, tags, &mut conn, data_path)?
|
||||||
}
|
}
|
||||||
KeepModes::Get => {
|
KeepModes::Get => {
|
||||||
crate::modes::get::mode_get(&mut cmd, args, ids, tags, &mut conn, data_path)?
|
crate::modes::get::mode_get(&mut cmd, &args, ids, tags, &mut conn, data_path)?
|
||||||
}
|
}
|
||||||
KeepModes::Diff => {
|
KeepModes::Diff => {
|
||||||
crate::modes::diff::mode_diff(&mut cmd, args, ids, tags, &mut conn, data_path)?
|
crate::modes::diff::mode_diff(&mut cmd, &args, ids, tags, &mut conn, data_path)?
|
||||||
}
|
}
|
||||||
KeepModes::List => {
|
KeepModes::List => {
|
||||||
crate::modes::list::mode_list(&mut cmd, args, ids, tags, &mut conn, data_path)?
|
crate::modes::list::mode_list(&mut cmd, &args, ids, tags, &mut conn, data_path)?
|
||||||
}
|
}
|
||||||
KeepModes::Update => {
|
KeepModes::Update => {
|
||||||
crate::modes::update::mode_update(&mut cmd, args, ids, tags, &mut conn, data_path)?
|
crate::modes::update::mode_update(&mut cmd, &args, ids, tags, &mut conn, data_path)?
|
||||||
}
|
}
|
||||||
KeepModes::Info => {
|
KeepModes::Info => {
|
||||||
crate::modes::info::mode_info(&mut cmd, args, ids, tags, &mut conn, data_path)?
|
crate::modes::info::mode_info(&mut cmd, &args, ids, tags, &mut conn, data_path)?
|
||||||
}
|
}
|
||||||
KeepModes::Delete => {
|
KeepModes::Delete => {
|
||||||
crate::modes::delete::mode_delete(&mut cmd, args, ids, tags, &mut conn, data_path)?
|
crate::modes::delete::mode_delete(&mut cmd, &args, ids, tags, &mut conn, data_path)?
|
||||||
}
|
}
|
||||||
KeepModes::Status => crate::modes::status::mode_status(&mut cmd, args, data_path, db_path)?,
|
KeepModes::Status => crate::modes::status::mode_status(&mut cmd, &args, data_path, db_path)?,
|
||||||
_ => todo!(),
|
_ => todo!(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ pub fn store_item_digest_value(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cmd_args_digest_type(cmd: &mut Command, args: Args) -> DigestType {
|
pub fn cmd_args_digest_type(cmd: &mut Command, args: &Args) -> DigestType {
|
||||||
let digest_name = args
|
let digest_name = args
|
||||||
.item
|
.item
|
||||||
.digest
|
.digest
|
||||||
@@ -142,7 +142,7 @@ pub fn cmd_args_digest_type(cmd: &mut Command, args: Args) -> DigestType {
|
|||||||
digest_type_opt.unwrap()
|
digest_type_opt.unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cmd_args_compression_type(cmd: &mut Command, args: Args) -> CompressionType {
|
pub fn cmd_args_compression_type(cmd: &mut Command, args: &Args) -> CompressionType {
|
||||||
let compression_name = args
|
let compression_name = args
|
||||||
.item
|
.item
|
||||||
.compression
|
.compression
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use rusqlite::Connection;
|
|||||||
|
|
||||||
pub fn mode_delete(
|
pub fn mode_delete(
|
||||||
cmd: &mut Command,
|
cmd: &mut Command,
|
||||||
_args: crate::Args,
|
_args: &crate::Args,
|
||||||
ids: &mut Vec<i64>,
|
ids: &mut Vec<i64>,
|
||||||
tags: &mut Vec<String>,
|
tags: &mut Vec<String>,
|
||||||
conn: &mut Connection,
|
conn: &mut Connection,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ use std::process::Stdio;
|
|||||||
|
|
||||||
pub fn mode_diff(
|
pub fn mode_diff(
|
||||||
cmd: &mut Command,
|
cmd: &mut Command,
|
||||||
_args: crate::Args,
|
_args: &crate::Args,
|
||||||
ids: &mut Vec<i64>,
|
ids: &mut Vec<i64>,
|
||||||
tags: &mut Vec<String>,
|
tags: &mut Vec<String>,
|
||||||
conn: &mut rusqlite::Connection,
|
conn: &mut rusqlite::Connection,
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ use std::str::FromStr;
|
|||||||
|
|
||||||
pub fn mode_get(
|
pub fn mode_get(
|
||||||
cmd: &mut Command,
|
cmd: &mut Command,
|
||||||
args: crate::Args,
|
args: &crate::Args,
|
||||||
ids: &mut Vec<i64>,
|
ids: &mut Vec<i64>,
|
||||||
tags: &mut Vec<String>,
|
tags: &mut Vec<String>,
|
||||||
conn: &mut rusqlite::Connection,
|
conn: &mut rusqlite::Connection,
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ use prettytable::{Attr, Cell, Row, Table};
|
|||||||
|
|
||||||
pub fn mode_info(
|
pub fn mode_info(
|
||||||
cmd: &mut Command,
|
cmd: &mut Command,
|
||||||
args: crate::Args,
|
args: &crate::Args,
|
||||||
ids: &mut Vec<i64>,
|
ids: &mut Vec<i64>,
|
||||||
tags: &mut Vec<String>,
|
tags: &mut Vec<String>,
|
||||||
conn: &mut rusqlite::Connection,
|
conn: &mut rusqlite::Connection,
|
||||||
@@ -50,7 +50,7 @@ pub fn mode_info(
|
|||||||
|
|
||||||
fn show_item(
|
fn show_item(
|
||||||
item: Item, // Using the provided struct definition
|
item: Item, // Using the provided struct definition
|
||||||
args: crate::Args,
|
args: &crate::Args,
|
||||||
conn: &mut rusqlite::Connection,
|
conn: &mut rusqlite::Connection,
|
||||||
data_path: PathBuf,
|
data_path: PathBuf,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use prettytable::{Attr, Cell, Row, Table};
|
|||||||
|
|
||||||
pub fn mode_list(
|
pub fn mode_list(
|
||||||
cmd: &mut clap::Command,
|
cmd: &mut clap::Command,
|
||||||
args: crate::Args,
|
args: &crate::Args,
|
||||||
ids: &mut Vec<i64>,
|
ids: &mut Vec<i64>,
|
||||||
tags: &Vec<String>,
|
tags: &Vec<String>,
|
||||||
conn: &mut rusqlite::Connection,
|
conn: &mut rusqlite::Connection,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use chrono::Utc;
|
|||||||
|
|
||||||
pub fn mode_save(
|
pub fn mode_save(
|
||||||
cmd: &mut Command,
|
cmd: &mut Command,
|
||||||
args: crate::Args,
|
args: &crate::Args,
|
||||||
ids: &mut Vec<i64>,
|
ids: &mut Vec<i64>,
|
||||||
tags: &mut Vec<String>,
|
tags: &mut Vec<String>,
|
||||||
conn: &mut Connection,
|
conn: &mut Connection,
|
||||||
@@ -36,8 +36,8 @@ pub fn mode_save(
|
|||||||
tags.push("none".to_string());
|
tags.push("none".to_string());
|
||||||
}
|
}
|
||||||
|
|
||||||
let digest_type = cmd_args_digest_type(cmd, args);
|
let digest_type = cmd_args_digest_type(cmd, &args);
|
||||||
let compression_type = cmd_args_compression_type(cmd, args);
|
let compression_type = cmd_args_compression_type(cmd, &args);
|
||||||
debug!("MAIN: Compression type: {}", compression_type);
|
debug!("MAIN: Compression type: {}", compression_type);
|
||||||
debug!("MAIN: Digest type: {}", digest_type);
|
debug!("MAIN: Digest type: {}", digest_type);
|
||||||
|
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ fn build_digest_table() -> Table {
|
|||||||
|
|
||||||
pub fn mode_status(
|
pub fn mode_status(
|
||||||
_cmd: &mut Command,
|
_cmd: &mut Command,
|
||||||
_args: crate::Args,
|
_args: &crate::Args,
|
||||||
data_path: PathBuf,
|
data_path: PathBuf,
|
||||||
db_path: PathBuf,
|
db_path: PathBuf,
|
||||||
) -> Result<(), anyhow::Error> {
|
) -> Result<(), anyhow::Error> {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use rusqlite::Connection;
|
|||||||
|
|
||||||
pub fn mode_update(
|
pub fn mode_update(
|
||||||
cmd: &mut Command,
|
cmd: &mut Command,
|
||||||
args: crate::Args,
|
args: &crate::Args,
|
||||||
ids: &mut Vec<i64>,
|
ids: &mut Vec<i64>,
|
||||||
tags: &mut Vec<String>,
|
tags: &mut Vec<String>,
|
||||||
conn: &mut Connection,
|
conn: &mut Connection,
|
||||||
|
|||||||
Reference in New Issue
Block a user