File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,9 @@ import (
13
13
)
14
14
15
15
var (
16
+ Version = ""
17
+ CommitSHA = ""
18
+
16
19
term = termenv .ColorProfile ()
17
20
theme Theme
18
21
33
36
34
37
inodes = flag .Bool ("inodes" , false , "list inode information instead of block usage" )
35
38
jsonOutput = flag .Bool ("json" , false , "output all devices in JSON format" )
39
+ version = flag .Bool ("version" , false , "display version" )
36
40
)
37
41
38
42
// renderTables renders all tables.
@@ -160,6 +164,18 @@ func parseHideFs(hideFs string) map[string]struct{} {
160
164
func main () {
161
165
flag .Parse ()
162
166
167
+ if * version {
168
+ if len (CommitSHA ) > 7 {
169
+ CommitSHA = CommitSHA [:7 ]
170
+ }
171
+ if Version == "" {
172
+ Version = "unknown"
173
+ CommitSHA = "built from source"
174
+ }
175
+ fmt .Printf ("duf %s (%s)\n " , Version , CommitSHA )
176
+ os .Exit (0 )
177
+ }
178
+
163
179
// validate flags
164
180
var err error
165
181
theme , err = loadTheme (* themeOpt )
You can’t perform that action at this time.
0 commit comments