show version

This commit is contained in:
Timon Ringwald 2022-08-29 13:48:46 +02:00
parent 90265e7080
commit c4870bfe0d
3 changed files with 15 additions and 1 deletions

5
go.mod
View File

@ -2,7 +2,10 @@ module git.milar.in/milarin/diskspace
go 1.18
require github.com/fatih/color v1.13.0
require (
git.milar.in/milarin/buildinfo v1.0.0
github.com/fatih/color v1.13.0
)
require (
github.com/mattn/go-colorable v0.1.9 // indirect

2
go.sum
View File

@ -1,3 +1,5 @@
git.milar.in/milarin/buildinfo v1.0.0 h1:tw98GupUYl/0a/3aPGuezhE4wseycOSsbcLp70hy60U=
git.milar.in/milarin/buildinfo v1.0.0/go.mod h1:arI9ZoENOgcZcanv25k9y4dKDUhPp0buJrlVerGruas=
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=

View File

@ -12,6 +12,7 @@ import (
"syscall"
"time"
"git.milar.in/milarin/buildinfo"
"github.com/fatih/color"
)
@ -24,6 +25,8 @@ var (
ColorGreen = color.New(color.FgGreen)
IconTheme = flag.String("i", "unicode", "icon theme (currently supported: default, unicode, nerd)")
ShowVersion = flag.Bool("v", false, "show version and exit")
)
// FIXME sometimes sorting not applied after removing items
@ -34,6 +37,12 @@ var (
// TODO autocomplete on TAB (see arrow up issue: raw necessary?)
func main() {
flag.Parse()
if *ShowVersion {
buildinfo.Print(buildinfo.Options{})
return
}
rootPath := flag.Arg(0)
mounts, err := Mounts()