feat: Add --reverse-sort flag for non-interactive mode#436
Merged
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
Contributor
Author
|
@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
Contributor
Author
|
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:
|
dundee
approved these changes
Sep 18, 2025
Owner
|
Very nice contribution! Thank you. |
Contributor
Author
|
@dundee no problem. i use the tool daily so thought it would be nice to add |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.