diff --git a/README.md b/README.md index b1c0ec92e..b2da1ac50 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ Flags: -a, --show-apparent-size Show apparent size -d, --show-disks Show all mounted disks -C, --show-item-count Show number of items in directory + -M, --show-mtime Show latest mtime of items in directory -B, --show-relative-size Show relative size --si Show sizes with decimal SI prefixes (kB, MB, GB) instead of binary prefixes (KiB, MiB, GiB) --storage-path string Path to persistent key-value storage directory (default is /tmp/badger) (default "/tmp/badger") diff --git a/cmd/gdu/app/app.go b/cmd/gdu/app/app.go index 96bc77e31..6007cab3d 100644 --- a/cmd/gdu/app/app.go +++ b/cmd/gdu/app/app.go @@ -57,6 +57,7 @@ type Flags struct { ShowRelativeSize bool `yaml:"show-relative-size"` ShowVersion bool `yaml:"-"` ShowItemCount bool `yaml:"show-item-count"` + ShowMTime bool `yaml:"show-mtime"` NoColor bool `yaml:"no-color"` NoMouse bool `yaml:"no-mouse"` NonInteractive bool `yaml:"non-interactive"` @@ -277,6 +278,11 @@ func (a *App) createUI() (UI, error) { ui.SetShowItemCount() }) } + if a.Flags.ShowMTime { + opts = append(opts, func(ui *tui.UI) { + ui.SetShowMTime() + }) + } if a.Flags.NoDelete { opts = append(opts, func(ui *tui.UI) { ui.SetNoDelete() diff --git a/cmd/gdu/main.go b/cmd/gdu/main.go index 4b40fad58..f35e641fd 100644 --- a/cmd/gdu/main.go +++ b/cmd/gdu/main.go @@ -67,6 +67,7 @@ func init() { flags.BoolVarP(&af.ShowRelativeSize, "show-relative-size", "B", false, "Show relative size") flags.BoolVarP(&af.NoColor, "no-color", "c", false, "Do not use colorized output") flags.BoolVarP(&af.ShowItemCount, "show-item-count", "C", false, "Show number of items in directory") + flags.BoolVarP(&af.ShowMTime, "show-mtime", "M", false, "Show latest mtime of items in directory") flags.BoolVarP(&af.NonInteractive, "non-interactive", "n", false, "Do not run in interactive mode") flags.BoolVarP(&af.NoProgress, "no-progress", "p", false, "Do not show progress in non-interactive mode") flags.BoolVarP(&af.Summarize, "summarize", "s", false, "Show only a total in non-interactive mode") diff --git a/gdu.1.md b/gdu.1.md index 2ffd8b1ec..62af79302 100644 --- a/gdu.1.md +++ b/gdu.1.md @@ -58,6 +58,8 @@ non-interactive mode **-C**, **\--show-item-count**\[=false\] Show number of items in directory +**-M**, **\--show-mtime**\[=false\] Show latest mtime of items in directory + **\--si**\[=false\] Show sizes with decimal SI prefixes (kB, MB, GB) instead of binary prefixes (KiB, MiB, GiB) **\--no-prefix**\[=false\] Show sizes as raw numbers without any prefixes (SI or binary) in non-interactive mode diff --git a/tui/tui.go b/tui/tui.go index eae3d6dcc..c895d3eac 100644 --- a/tui/tui.go +++ b/tui/tui.go @@ -257,6 +257,11 @@ func (ui *UI) SetShowItemCount() { ui.showItemCount = true } +// SetShowMTime sets the flag to show last modification time of items in directory +func (ui *UI) SetShowMTime() { + ui.showMtime = true +} + // SetNoDelete disables all write operations func (ui *UI) SetNoDelete() { ui.noDelete = true diff --git a/tui/tui_test.go b/tui/tui_test.go index 46821ecde..0e80d7afb 100644 --- a/tui/tui_test.go +++ b/tui/tui_test.go @@ -760,6 +760,18 @@ func TestSetShowItemCount(t *testing.T) { assert.Equal(t, ui.showItemCount, true) } +func TestSetShowMTime(t *testing.T) { + simScreen := testapp.CreateSimScreen() + defer simScreen.Fini() + + app := testapp.CreateMockedApp(true) + ui := CreateUI(app, simScreen, &bytes.Buffer{}, false, true, false, false, false) + + ui.SetShowMTime() + + assert.Equal(t, ui.showMtime, true) +} + func TestNoDelete(t *testing.T) { simScreen := testapp.CreateSimScreen() defer simScreen.Fini()