breaktime/cmd/toggle.go

26 lines
467 B
Go

/*
Copyright © 2023 Brian Buller <brian@bullercodeworks.com>
*/
package cmd
import (
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
// toggleCmd represents the toggle command
var toggleCmd = &cobra.Command{
Use: "toggle",
Short: "Toggle timer off/on",
Run: func(cmd *cobra.Command, args []string) {
if viper.GetBool("active") {
stopCmd.Run(cmd, args)
} else {
startCmd.Run(cmd, args)
}
},
}
func init() { rootCmd.AddCommand(toggleCmd) }