feat: update subcmd
This commit is contained in:
@@ -4,18 +4,28 @@ use std::ops::Add;
|
||||
use std::path::PathBuf;
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
use clap::Args;
|
||||
use rust_util::{iff, opt_result, success, XResult};
|
||||
use rust_util::util_time::get_current_millis;
|
||||
use simpledateformat::format_human2;
|
||||
|
||||
use crate::file;
|
||||
|
||||
pub fn info(path: PathBuf, raw_meta: bool) -> XResult<()> {
|
||||
let path_display = format!("{}", path.display());
|
||||
let mut file_in = opt_result!(File::open(path), "Open file: {} failed: {}", &path_display);
|
||||
#[derive(Debug, Args)]
|
||||
pub struct CmdInfo {
|
||||
/// File
|
||||
pub path: PathBuf,
|
||||
/// Show raw meta
|
||||
#[arg(long, default_value_t = false)]
|
||||
pub raw_meta: bool,
|
||||
}
|
||||
|
||||
pub fn info(cmd_info: &CmdInfo) -> XResult<()> {
|
||||
let path_display = format!("{}", cmd_info.path.display());
|
||||
let mut file_in = opt_result!(File::open(&cmd_info.path), "Open file: {} failed: {}", &path_display);
|
||||
let meta = opt_result!(file::read_tiny_encrypt_meta_and_normalize(&mut file_in), "Read file: {}, failed: {}", &path_display);
|
||||
|
||||
if raw_meta {
|
||||
if cmd_info.raw_meta {
|
||||
success!("Meta data:\n{}", serde_json::to_string_pretty(&meta).expect("SHOULD NOT HAPPEN"));
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user