2024-09-17 21:02:36 +00:00
|
|
|
/*
|
|
|
|
Copyright © 2024 NAME HERE <EMAIL ADDRESS>
|
|
|
|
*/
|
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2024-09-19 21:11:28 +00:00
|
|
|
"strings"
|
2024-09-17 21:02:36 +00:00
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
2024-09-19 21:11:28 +00:00
|
|
|
"github.com/spf13/viper"
|
2024-09-17 21:02:36 +00:00
|
|
|
)
|
|
|
|
|
2024-09-19 19:21:09 +00:00
|
|
|
// favCmd represents the fav command
|
|
|
|
var favCmd = &cobra.Command{
|
|
|
|
Use: "fav",
|
2024-09-19 21:11:28 +00:00
|
|
|
Short: "Retrieves the favorite mensa menus",
|
|
|
|
Long: `Retrieves the favorite mensa menus for the current day.
|
|
|
|
You can add mensas to your favorites using the search command.`,
|
2024-09-17 21:02:36 +00:00
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2024-09-19 21:11:28 +00:00
|
|
|
favorites := viper.GetStringSlice("favorites")
|
|
|
|
if len(favorites) == 0 {
|
|
|
|
fmt.Println("You have no favorites")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
fmt.Println("Your favorites: " + strings.Join(favorites, ", "))
|
|
|
|
|
2024-09-17 21:02:36 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
2024-09-19 19:21:09 +00:00
|
|
|
rootCmd.AddCommand(favCmd)
|
2024-09-17 21:02:36 +00:00
|
|
|
|
|
|
|
// Here you will define your flags and configuration settings.
|
|
|
|
|
|
|
|
// Cobra supports Persistent Flags which will work for this command
|
|
|
|
// and all subcommands, e.g.:
|
2024-09-19 19:21:09 +00:00
|
|
|
// favCmd.PersistentFlags().String("foo", "", "A help for foo")
|
2024-09-17 21:02:36 +00:00
|
|
|
|
|
|
|
// Cobra supports local flags which will only run when this command
|
|
|
|
// is called directly, e.g.:
|
2024-09-19 19:21:09 +00:00
|
|
|
// favCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
2024-09-17 21:02:36 +00:00
|
|
|
}
|