/* Copyright © 2021 NAME HERE */ package cmd import ( "fmt" "log" "strconv" "github.com/spf13/cobra" ) // showCmd represents the show command var showCmd = &cobra.Command{ Use: "show", Short: "A brief description of your command", Long: `A longer description that spans multiple lines and likely contains examples and usage of using your command. For example: Cobra is a CLI library for Go that empowers applications. This application is a tool to generate the needed files to quickly create a Cobra application.`, PreRunE: func(cmd *cobra.Command, args []string) error { id, err := strconv.Atoi(args[0]) if err != nil { return err } _, err = App.GetDiaryEntry(int64(id)) if err != nil { return err } return nil }, Run: func(cmd *cobra.Command, args []string) { entry_id, _ := strconv.Atoi(args[0]) var entry, err = App.GetDiaryEntry(int64(entry_id)) if err != nil { log.Fatal(err) } var notes = App.GetDiaryEntryNotes(entry.Id) PrintEntry(entry) fmt.Println() PrintNotes(notes) }, } func init() { rootCmd.AddCommand(showCmd) }