Closed erhhung closed 5 months ago
Hi, I took a wack at this (I use the tool and I have programming skills, so why not)
First I decided to do it the long route and the ripple effect of changing the main UI factory (CreateUI
) was too much. I got to admit I barely know the project, but that was a fun exercise having to change a bunch of places including a lot of test that use the default factory to create the UI object they work with
The second approach was much more simple and involved using the opts and a setter
I would like to add some unit tests, what would be some test cases to include with it. Please let me know if this approach is appropriate, these are the changes I did (I kept the names consistent with the existing code base):
tui/tui.go
// line: 204
func (ui *UI) SetShowItemCount() {
ui.showItemCount = true
}
app/app.go
// line: 58
ShowItemCount bool `yaml:"show-item-count"`
// line: 271
if a.Flags.ShowItemCount {
opts = append(opts, func(ui *tui.UI) {
ui.SetShowItemCount()
})
}
main.go
// line: 71
flags.BoolVarP(&af.ShowItemCount, "show-item-count", "C", false, "Show number of items in directory")
Yes, I think the setter is the correct approach here.
Resolved in #332.
The option to toggle the display of the number of items in a directory is already available in the TUI by pressing
c
, but the items column is always hidden by default. There's no CLI option to show that column in the TUI and in non-interactive and export output modes, and also no way to set that in thegdu.yaml
config file.Describe the solution you'd like
Allow a CLI option, such as
--show-counts
/-C
, and corresponding config file settingshow-counts: true
to enable showing the number of items column by default (in JSON output, include explicititems
property instead of merely checking array length).An even better enhancement would be separating "number of items" values into distinct "number of files" and "number of subdirectories" counts (in JSON output, include
files
andsubdirs
properties instead ofitems
for directory objects).