-
Notifications
You must be signed in to change notification settings - Fork 180
feat: Add --reverse-sort flag for non-interactive mode #436
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add --reverse-sort boolean flag to command line interface - Enables reversing sort order from largest-to-smallest to smallest-to-largest - Only applies to non-interactive mode to address scrolling usability issues - Follows existing CLI argument patterns and conventions
- Add ReverseSort bool field to Flags struct for YAML config support - Pass ReverseSort parameter to CreateStdoutUI for non-interactive mode - Maintains backward compatibility with existing configuration options - Enables --reverse-sort flag to be stored in config files
- Update CreateStdoutUI function signature to accept reverseSort parameter - Add reverseSort field to UI struct for state tracking - Modify showDir function to conditionally apply reverse sorting: * Default: sort.Reverse() for largest-to-smallest (existing behavior) * With --reverse-sort: standard sort() for smallest-to-largest (new behavior) - Maintains performance with no additional overhead
- Add 6 new test functions to validate reverse sort behavior - Test reverse sort with various flag combinations (colors, summarize, top) - Test reverse sort with analysis files and different UI modes - Add strings import for test utilities - Ensure backward compatibility with existing test patterns - All new tests pass alongside existing 300+ test suite
- Add --reverse-sort flag to CLI help documentation in README.md - Add usage example showing reverse sort in non-interactive mode - Document reverse-sort configuration option in configuration.md - Maintain consistent documentation formatting and style - Provide clear explanation of feature purpose and usage
- Ignore compiled gdu binary from version control - Prevents accidental commit of build artifacts - Maintains clean repository structure
|
@dundee enjoy another PR (last one was empty folder press enter , error if u remember) |
- Add missing reverseSort parameter to CreateStdoutUI function call - Fixes compilation error in stdout_linux_test.go - Maintains consistency with updated function signature
|
forgot about that one yikes |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #436 +/- ##
==========================================
- Coverage 83.50% 83.50% -0.01%
==========================================
Files 46 46
Lines 4408 4414 +6
==========================================
+ Hits 3681 3686 +5
- Misses 655 656 +1
Partials 72 72 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Very nice contribution! Thank you. |
|
@dundee no problem. i use the tool daily so thought it would be nice to add |
Summary
This PR implements a
--reverse-sortcommand-line flag that reverses the default sorting order in non-interactive mode, displaying files from smallest to largest instead of largest to smallest.Fixes #435
Problem
In non-interactive mode, gdu sorts entries from largest to smallest by default. When analyzing directories with many files, users must scroll through large files to view smaller ones, creating a poor user experience especially in terminal environments with limited screen space.
Solution
Added
--reverse-sortflag that:--summarize,--top, etc.)Changes Made
--reverse-sortflag with help textReverseSortfield toFlagsstructstdout/stdout.goUsage Examples
Testing
Performance
Zero performance impact - uses same sorting algorithms with conditional reverse application.