Skip to content

feat: add --summary flag to display file statistics#1709

Open
avih7531 wants to merge 2 commits intoeza-community:mainfrom
avih7531:feat/summary-flag
Open

feat: add --summary flag to display file statistics#1709
avih7531 wants to merge 2 commits intoeza-community:mainfrom
avih7531:feat/summary-flag

Conversation

@avih7531
Copy link
Copy Markdown

@avih7531 avih7531 commented Feb 5, 2026

Description

This PR adds a new --summary flag that displays a summary of file counts at the end of eza's output.

Changes

  • New flag: --summary (no short flag, as -s is used by --sort)
  • Summary display: Shows counts of directories, files, and symlinks, plus total
  • Icon support: Respects the --icons flag setting
  • Recursive counting: Works correctly with both --recurse and --tree modes
  • Clean formatting: Proper alignment with and without icons

Testing

✅ All local cargo tests pass (331 unit tests + 7 integration tests)

Tested manually with:

  • Basic usage: eza --summary
  • With icons: eza --summary --icons=always
  • Without icons: eza --summary --icons=never
  • Recursive mode: eza --summary --recurse
  • Tree mode: eza --summary --tree
  • Long view: eza --summary --long

Example Output

With icons:

  Directories: 4
  Files: 4
󰌸  Symlinks: 1
Total: 9

Without icons:

Directories: 4
Files: 4
Symlinks: 1
Total: 9

Implementation Details

  • Updated to work with clap-based parser (compatible with PR Use clap instead of custom command line arguments parser #1447)
  • Tree mode properly counts all files recursively using count_files_recursive()
  • Icon display respects --icons flag (always/auto/never)
  • Symlinks are counted separately from files and directories
  • Summary only displays when --summary flag is present

Checklist

  • Added completions for bash, zsh, fish, nushell
  • Added documentation to the man page
  • Added option to the help flag
  • Added option to the README.md
  • Follows conventional commits
  • Code compiles without warnings
  • No linter errors
  • All local tests pass
  • Properly formatted output
  • Added comprehensive test coverage (7 test cases)

Test Coverage

Added integration tests:

  • tests/cmd/summary_all.* - Basic summary
  • tests/cmd/summary_icons_all.* - Summary with icons
  • tests/cmd/summary_tree_unix.* - Tree mode with summary
  • tests/gen/summary_nix.* - Nix environment test
  • tests/gen/summary_long_nix.* - Long view with summary
  • tests/gen/summary_tree_nix.* - Tree view with summary
  • tests/gen/summary_recurse_nix.* - Recursive mode with summary

Adds a new --summary flag that displays a summary at the end of output
showing counts of directories, files, and symlinks. The summary respects
the --icons flag, displaying appropriate icons when enabled.

This implementation is compatible with the new clap-based CLI parser
introduced in PR eza-community#1447.

Features:
- Counts all displayed items (files, directories, symlinks separately)
- Works with --recurse to count all items recursively
- Works with --tree to count all items in the tree view
- Icon support: shows folder/file/symlink icons when --icons is enabled
- Plain text mode when icons are disabled or --icons=never
- Clean, aligned output formatting

Changes:
- Added --summary flag to clap parser in src/options/parser.rs
- Added Summary struct and counting logic in src/main.rs
- Updated View struct in src/output/mod.rs and src/options/view.rs
- Added man page documentation in man/eza.1.md
- Added shell completions for bash, zsh, fish, and nushell
- Updated README.md
- Added integration tests for --summary flag

Tests:
- Added tests/cmd/summary_all.* for basic summary
- Added tests/cmd/summary_icons_all.* for summary with icons
- Added tests/cmd/summary_tree_unix.* for tree mode with summary
- All local cargo tests pass (331 unit tests + integration tests)
- Added tests/gen/summary_nix.* for basic summary
- Added tests/gen/summary_long_nix.* for summary with long view
- Added tests/gen/summary_tree_nix.* for summary with tree view
- Added tests/gen/summary_recurse_nix.* for summary with recursive mode

These tests validate the --summary flag works correctly in the Nix
build environment with the test_dir structure.
@avih7531
Copy link
Copy Markdown
Author

avih7531 commented Feb 5, 2026

This PR is a better #1699

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant