solidiquis / erdtree

A modern, cross-platform, multi-threaded, and general purpose filesystem and disk-usage utility that is aware of .gitignore and hidden file rules.
https://crates.io/crates/erdtree
MIT License
2.39k stars 64 forks source link

'erd -y iflat --sort size --dirs-only' does not sort as expected; also: should the order of the params matter? #224

Open johnnyutahh opened 1 year ago

johnnyutahh commented 1 year ago

erd -y iflat --sort size --dirs-only does not appear to sort the dirs properly.

My guess is that it's sorting the non-dirs, -y iflat output first and then applying the --dirs-only "filter"... but I've not tested nor investigated my guess, so it (my guess) may not be worth much.

The order of the -y, --sort, --dirs-only parameters seems to have no effect, but I may not have tried every combination. Broader question: do we want the order to matter? I propose it should not.

$ erd --version
erdtree 3.1.2
$ type erd
erd is hashed (/opt/homebrew/bin/erd)
$
$ pwd
/Users/XXXX/gitrs/erdtree
$
$ erd -y iflat --sort size --dirs-only
6139904 B   erdtree
5607424 B   assets
 335872 B   src
  81920 B   src/context
  24576 B   src/context/config
  16384 B   src/context/config/toml
  53248 B   src/tree
  24576 B   src/tree/node
  49152 B   src/render
  20480 B   src/render/layout
  16384 B   src/render/grid
   4096 B   src/render/long
  45056 B   src/fs
  28672 B   src/fs/permissions
  32768 B   src/disk_usage
  24576 B   src/disk_usage/file_size
  24576 B   src/icons
  16384 B   src/styles
  12288 B   src/tty
  77824 B   tests
  24576 B   tests/data
   4096 B   tests/data/the_yellow_king
   4096 B   tests/data/dream_cycle
   4096 B   tests/data/lipsum
   4096 B   tests/utils
   4096 B   tests/hardlinks
   4096 B   scripts
        -   example

27 directories
$
$
$
$ git remote show origin | grep URL; git rev-parse HEAD
  Fetch URL: https://github.com/solidiquis/erdtree
  Push  URL: https://github.com/solidiquis/erdtree
202fae12b0cb4c0ce0a948060104df855e9ec3c5
$
$ sw_vers
ProductName:    macOS
ProductVersion: 12.6.5
BuildVersion:   21G531
$ date
Sun Jul  2 15:29:57 EDT 2023
$
solidiquis commented 1 year ago

Off to investigate

solidiquis commented 1 year ago

Ahh yeah so I could see why this is confusing. erdtree sorts in such a way that makes a coherent tree structure:

Screen Shot 2023-07-03 at 8 46 55 AM

I didn't think of the effects this would have on the flat and iflat layouts. I will probably have sorting work differently between the flat/iflat layouts and the regular/inverted layouts.

johnnyutahh commented 1 year ago

I didn't think of the effects this would have on the flat and iflat layouts. I will probably have sorting work differently between the flat/iflat layouts and the regular/inverted layouts.

That's what I was thinking and makes perfect sense to me.

@solidiquis - is this comfortably feasible for a future erd release?

solidiquis commented 1 year ago

Yes I'm working on it today actually :)

Edit: the next release should be out later this week.