/* Copyright © 2021 NAME HERE */ package cmd import ( "fmt" "github.com/spf13/cobra" ) // addCmd represents the add command var addCmd = &cobra.Command{ Use: "add [entry title]", Args: cobra.ExactArgs(1), Short: "Add a new diary entry with the given title", Long: `Add a new diary entry, for example and usage of using your command. For example: $ diary add "Issue when fixing bad data in prod" 1134 The returned number is the ID of the added entry. This ID can be used in other commands. `, Run: func(cmd *cobra.Command, args []string) { var entry = App.Db.NewDiaryEntry(args[0]) fmt.Println(entry.Id) }, } func init() { rootCmd.AddCommand(addCmd) }