refactor: improve code formatting and readability in SQL and function calls
This commit is contained in:
committed by
Andrew Phillips (aider)
parent
dd8f828ed3
commit
5a6a8ee97b
@@ -1,28 +1,28 @@
|
||||
use humansize::{BINARY, FormatSizeOptions};
|
||||
use clap::Command;
|
||||
use log::debug;
|
||||
use prettytable::format::TableFormat;
|
||||
use clap::error::ErrorKind;
|
||||
use regex::Regex;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use rusqlite::Connection;
|
||||
use std::str::FromStr;
|
||||
use crate::Args;
|
||||
use crate::compression_engine::CompressionType;
|
||||
use crate::db::Item;
|
||||
use crate::db::Meta;
|
||||
use crate::db::store_meta;
|
||||
use crate::compression_engine::CompressionType;
|
||||
use crate::digest_engine::DigestType;
|
||||
use crate::Args;
|
||||
use clap::Command;
|
||||
use clap::error::ErrorKind;
|
||||
use humansize::{BINARY, FormatSizeOptions};
|
||||
use log::debug;
|
||||
use prettytable::format::TableFormat;
|
||||
use regex::Regex;
|
||||
use rusqlite::Connection;
|
||||
use std::collections::HashMap;
|
||||
use std::env;
|
||||
use std::str::FromStr;
|
||||
|
||||
pub fn get_meta_from_env() -> HashMap<String, String> {
|
||||
debug!("MAIN: Getting meta from KEEP_META_*");
|
||||
debug!("COMMON: Getting meta from KEEP_META_*");
|
||||
let re = Regex::new(r"^KEEP_META_(.+)$").unwrap();
|
||||
let mut meta_env: HashMap<String, String> = HashMap::new();
|
||||
for (key, value) in env::vars() {
|
||||
if let Some(meta_name_caps) = re.captures(key.as_str()) {
|
||||
let name = String::from(meta_name_caps.get(1).unwrap().as_str());
|
||||
debug!("MAIN: Found meta: {}={}", name.clone(), value.clone());
|
||||
debug!("COMMON: Found meta: {}={}", name.clone(), value.clone());
|
||||
meta_env.insert(name, value.clone());
|
||||
}
|
||||
}
|
||||
@@ -101,7 +101,6 @@ pub fn get_format_box_chars_no_border_line_separator() -> TableFormat {
|
||||
.build()
|
||||
}
|
||||
|
||||
|
||||
pub fn get_digest_type_meta(digest_type: DigestType) -> String {
|
||||
format!("digest_{}", digest_type.to_string().to_lowercase())
|
||||
}
|
||||
@@ -136,7 +135,7 @@ pub fn cmd_args_digest_type(cmd: &mut Command, args: &Args) -> DigestType {
|
||||
ErrorKind::InvalidValue,
|
||||
format!("Unknown digest type: {}", digest_name),
|
||||
)
|
||||
.exit();
|
||||
.exit();
|
||||
}
|
||||
|
||||
digest_type_opt.unwrap()
|
||||
@@ -155,7 +154,7 @@ pub fn cmd_args_compression_type(cmd: &mut Command, args: &Args) -> CompressionT
|
||||
ErrorKind::InvalidValue,
|
||||
format!("Unknown compression type: {}", compression_name),
|
||||
)
|
||||
.exit();
|
||||
.exit();
|
||||
}
|
||||
|
||||
compression_type_opt.unwrap()
|
||||
|
||||
Reference in New Issue
Block a user