File tree Expand file tree Collapse file tree 1 file changed +18
-0
lines changed
Expand file tree Collapse file tree 1 file changed +18
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,10 @@ import (
1313
1414var (
1515 version string
16+
17+ flagSecond bool
18+ flagMinute bool
19+ flagHour bool
1620)
1721
1822var rootCmd = & cobra.Command {
@@ -32,6 +36,15 @@ var rootCmd = &cobra.Command{
3236 }
3337
3438 base := time .Second
39+ switch {
40+ case flagSecond :
41+ base = time .Second
42+ case flagMinute :
43+ base = time .Minute
44+ case flagHour :
45+ base = time .Hour
46+ }
47+
3548 m := model .New (& model.Config {
3649 Duration : time .Duration (t * float64 (base )),
3750 })
@@ -61,4 +74,9 @@ func init() {
6174 }
6275 }
6376 rootCmd .Version = version
77+
78+ rootCmd .Flags ().BoolVar (& flagSecond , "second" , false , "set the time unit to seconds (default)" )
79+ rootCmd .Flags ().BoolVar (& flagMinute , "minute" , false , "set the time unit to minutes" )
80+ rootCmd .Flags ().BoolVar (& flagHour , "hour" , false , "set the time unit to hours" )
81+ rootCmd .MarkFlagsMutuallyExclusive ("second" , "minute" , "hour" )
6482}
You can’t perform that action at this time.
0 commit comments