feat(commands): Add json option to prune

This commit is contained in:
Alexander Weiss 2024-03-04 16:52:11 +01:00
parent 8561410129
commit fc8ce37639
4 changed files with 44 additions and 19 deletions

49
Cargo.lock generated
View File

@ -330,16 +330,6 @@ version = "2.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ed570934406eb16438a4e976b1b4500774099c13b8cb96eec99f620f05090ddf"
[[package]]
name = "bitmask-enum"
version = "2.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9990737a6d5740ff51cdbbc0f0503015cb30c390f6623968281eb214a520cfc0"
dependencies = [
"quote",
"syn 2.0.50",
]
[[package]]
name = "block-buffer"
version = "0.10.4"
@ -458,6 +448,12 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cfg_aliases"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e"
[[package]]
name = "chrono"
version = "0.4.34"
@ -1145,6 +1141,28 @@ dependencies = [
"syn 2.0.50",
]
[[package]]
name = "enumset"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "226c0da7462c13fb57e5cc9e0dc8f0635e7d27f276a3a7fd30054647f669007d"
dependencies = [
"enumset_derive",
"serde",
]
[[package]]
name = "enumset_derive"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e08b6c6ab82d70f08844964ba10c7babb716de2ecaeab9be5717918a5177d3af"
dependencies = [
"darling 0.20.6",
"proc-macro2",
"quote",
"syn 2.0.50",
]
[[package]]
name = "env_logger"
version = "0.8.4"
@ -1991,12 +2009,13 @@ dependencies = [
[[package]]
name = "nix"
version = "0.27.1"
version = "0.28.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
checksum = "ab2156c4fce2f8df6c499cc1c763e4394b7482525bf2a9701c9d79d215f519e4"
dependencies = [
"bitflags 2.4.2",
"cfg-if 1.0.0",
"cfg_aliases",
"libc",
]
@ -3001,7 +3020,7 @@ dependencies = [
[[package]]
name = "rustic_backend"
version = "0.1.1"
source = "git+https://github.com/rustic-rs/rustic_core.git#d17439568e046ddac90f9f1cc065e2c2770caf57"
source = "git+https://github.com/rustic-rs/rustic_core.git?branch=enumset#e4b006a209a6fa74357f8cc70c213a3a92301461"
dependencies = [
"aho-corasick",
"anyhow",
@ -3033,12 +3052,11 @@ dependencies = [
[[package]]
name = "rustic_core"
version = "0.2.0"
source = "git+https://github.com/rustic-rs/rustic_core.git#d17439568e046ddac90f9f1cc065e2c2770caf57"
source = "git+https://github.com/rustic-rs/rustic_core.git?branch=enumset#e4b006a209a6fa74357f8cc70c213a3a92301461"
dependencies = [
"aes256ctr_poly1305aes",
"anyhow",
"binrw",
"bitmask-enum",
"bytes",
"bytesize",
"cached",
@ -3055,6 +3073,7 @@ dependencies = [
"dunce",
"enum-map",
"enum-map-derive",
"enumset",
"filetime",
"futures",
"gethostname",

View File

@ -40,8 +40,8 @@ rustdoc-args = ["--document-private-items", "--generate-link-to-definition"]
[dependencies]
abscissa_core = { version = "0.7.0", default-features = false, features = ["application"] }
rustic_backend = { git = "https://github.com/rustic-rs/rustic_core.git", features = ["cli"] }
rustic_core = { git = "https://github.com/rustic-rs/rustic_core.git", features = ["cli"] }
rustic_backend = { git = "https://github.com/rustic-rs/rustic_core.git", branch = "enumset", features = ["cli"] }
rustic_core = { git = "https://github.com/rustic-rs/rustic_core.git", branch = "enumset", features = ["cli"] }
# allocators
jemallocator-global = { version = "0.3.2", optional = true }

View File

@ -14,6 +14,7 @@ log-file = "/path/to/rustic.log" # Default: not set
no-progress = false
progress-interval = "100ms"
dry-run = false
json = false
# Global env variables: These are set by rustic before calling a subcommand, e.g. rclone or commands
# defined in the repository options.
@ -99,7 +100,6 @@ exclude-if-present = [".nobackup", "CACHEDIR.TAG"] # Default: not set
custom-ignorefile = [".rusticignore", ".backupignore"] # Default: not set
one-file-system = false
exclude-larger-than = "100MB" # Default: not set
json = false
init = false
no-scan = false
quiet = false

View File

@ -35,7 +35,13 @@ impl PruneCmd {
let pruner = repo.prune_plan(&self.opts)?;
print_stats(&pruner.stats);
if config.global.json {
let mut stdout = std::io::stdout();
let debug: Vec<_> = pruner.stats.debug.0.iter().collect();
serde_json::to_writer_pretty(&mut stdout, &debug)?;
} else {
print_stats(&pruner.stats);
}
if config.global.dry_run {
repo.warm_up(pruner.repack_packs().into_iter())?;