mirror of
https://github.com/sreedevk/deduplicator.git
synced 2026-08-26 02:04:39 +00:00
Merge pull request #56 from sreedevk/feature/add-json-output
Version 0.2.1
This commit is contained in:
41
Cargo.lock
generated
41
Cargo.lock
generated
@@ -320,7 +320,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "deduplicator"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"bytesize",
|
||||
@@ -336,6 +336,8 @@ dependencies = [
|
||||
"pathdiff",
|
||||
"prettytable-rs",
|
||||
"rayon",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
@@ -707,9 +709,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.66"
|
||||
version = "1.0.69"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "18fb31db3f9bddb2ea821cde30a9f70117e3f119938b5ee630b7403aa6e2ead9"
|
||||
checksum = "134c189feb4956b20f6f547d2cf727d4c0fe06722b20a0eec87ed445a97f92da"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
@@ -824,9 +826,34 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.160"
|
||||
version = "1.0.192"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c"
|
||||
checksum = "bca2a08484b285dcb282d0f67b26cadc0df8b19f8c12502c13d966bf9482f001"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.192"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6c7207fbec9faa48073f3e3074cbe553af6ea512d7c21ba46e434e70ea9fbc1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.108"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"ryu",
|
||||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
@@ -842,9 +869,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.26"
|
||||
version = "2.0.39"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "45c3457aacde3c65315de5031ec191ce46604304d2446e803d71ade03308d970"
|
||||
checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "deduplicator"
|
||||
version = "0.2.0"
|
||||
version = "0.2.1"
|
||||
edition = "2021"
|
||||
description = "find,filter,delete Duplicates"
|
||||
repository = "https://github.com/sreedevk/deduplicator"
|
||||
@@ -28,6 +28,8 @@ memmap2 = "0.5.8"
|
||||
pathdiff = "0.2.1"
|
||||
prettytable-rs = "0.10.0"
|
||||
rayon = "1.6.1"
|
||||
serde = { version = "1.0.192", features = ["derive"] }
|
||||
serde_json = "1.0.108"
|
||||
unicode-segmentation = "1.10.0"
|
||||
|
||||
[profile.release]
|
||||
|
||||
@@ -21,6 +21,7 @@ Options:
|
||||
-f, --follow-links Follow links while scanning directories
|
||||
-h, --help Print help information
|
||||
-V, --version Print version information
|
||||
--json
|
||||
```
|
||||
### Examples
|
||||
|
||||
|
||||
@@ -3,13 +3,15 @@ use memmap2::Mmap;
|
||||
use std::fs;
|
||||
use std::hash::Hasher;
|
||||
use std::{fs::Metadata, path::PathBuf};
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
pub struct FileInfo {
|
||||
pub path: PathBuf,
|
||||
pub filemeta: Metadata,
|
||||
pub hash: Option<String>,
|
||||
pub size: u64,
|
||||
#[serde(skip)]
|
||||
pub filemeta: Metadata,
|
||||
}
|
||||
|
||||
impl FileInfo {
|
||||
|
||||
@@ -121,8 +121,13 @@ impl Formatter {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let output_table = Self::generate_table(raw, app_args)?;
|
||||
output_table.printstd();
|
||||
if app_args.json {
|
||||
let output_json = serde_json::to_string_pretty(&raw)?;
|
||||
println!("{}", output_json);
|
||||
} else {
|
||||
let output_table = Self::generate_table(raw, app_args)?;
|
||||
output_table.printstd();
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -19,8 +19,12 @@ fn main() -> Result<()> {
|
||||
let results = processor.sizewise()?.hashwise()?;
|
||||
|
||||
match app_args.interactive {
|
||||
false => { Formatter::print(results.files, &app_args)?; }
|
||||
true => { interactive::init(results.files, &app_args)?; }
|
||||
false => {
|
||||
Formatter::print(results.files, &app_args)?;
|
||||
}
|
||||
true => {
|
||||
interactive::init(results.files, &app_args)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -27,6 +27,9 @@ pub struct Params {
|
||||
/// Follow links while scanning directories
|
||||
#[arg(long, short)]
|
||||
pub follow_links: bool,
|
||||
/// print json output
|
||||
#[arg(long)]
|
||||
pub json: bool,
|
||||
}
|
||||
|
||||
impl Params {
|
||||
|
||||
Reference in New Issue
Block a user