Skip to content

Commit

Permalink
feat(commands): Add json option to prune
Browse files Browse the repository at this point in the history
  • Loading branch information
aawsome committed Mar 4, 2024
1 parent 8561410 commit fc8ce37
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 19 deletions.
49 changes: 34 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion config/full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion src/commands/prune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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())?;
Expand Down

0 comments on commit fc8ce37

Please sign in to comment.