diff --git a/z/trackCmd.go b/z/trackCmd.go index 81b0455..c071e49 100644 --- a/z/trackCmd.go +++ b/z/trackCmd.go @@ -4,6 +4,7 @@ import ( "os" "fmt" "github.com/spf13/cobra" + "github.com/spf13/viper" ) var trackCmd = &cobra.Command{ @@ -24,6 +25,20 @@ var trackCmd = &cobra.Command{ os.Exit(1) } + if project == "" && viper.GetString("project.default") != "" { + project = viper.GetString("project.default") + } + + if project == "" && viper.GetBool("project.mandatory") { + fmt.Println("project is mandatory but missing") + os.Exit(1) + } + + if task == "" && viper.GetBool("task.mandatory") { + fmt.Println("task is mandatory but missing") + os.Exit(1) + } + newEntry, err := NewEntry("", begin, finish, project, task, user) if err != nil { fmt.Printf("%s %+v\n", CharError, err)