mirror of
https://github.com/Threnklyn/zeit.git
synced 2026-05-18 21:03:30 +02:00
Add options to make project and tasks mandatory and set default project
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user