diff --git a/btrfs-snapshots-diff.py b/btrfs-snapshots-diff.py index 8cd1ce4..2a9ff6a 100755 --- a/btrfs-snapshots-diff.py +++ b/btrfs-snapshots-diff.py @@ -568,6 +568,9 @@ def main(): parser.add_argument( '-j', '--json', action='store_true', help='JSON output (commands only)' ) + parser.add_argument( + '--stats', action='store_true', help='Print simple statistics' + ) parser.add_argument( '--pretty', action='store_true', help=argparse.SUPPRESS ) @@ -619,6 +622,16 @@ def main(): exit(1) commands, paths = stream.decode(bogus=args.bogus) + if args.stats: + from collections import Counter + + print('Commands:') + command_counts = Counter(d["command"] for d in commands) + for key, count in command_counts.most_common(): + print(f'{count}\t{key}') + + exit(0) + if args.by_path: print(f'Found a valid Btrfs stream header, version {stream.version}\n') print_by_paths(paths, commands, args.filter, args.csv)