breaktime/cmd/break.go

28 lines
483 B
Go
Raw Permalink Normal View History

2023-03-31 14:51:41 +00:00
/*
Copyright © 2023 Brian Buller <brian@bullercodeworks.com>
*/
package cmd
import (
2023-03-31 16:07:03 +00:00
"time"
2023-03-31 14:51:41 +00:00
"github.com/spf13/cobra"
2023-03-31 16:07:03 +00:00
"github.com/spf13/viper"
2023-03-31 14:51:41 +00:00
)
// breakCmd represents the break command
var breakCmd = &cobra.Command{
Use: "break",
Short: "Start a break",
Run: func(cmd *cobra.Command, args []string) {
2023-03-31 16:07:03 +00:00
length := viper.GetDuration("breaklength")
viper.Set("lastbreak", time.Now().Add(length))
viper.WriteConfig()
2023-03-31 14:51:41 +00:00
},
}
func init() {
rootCmd.AddCommand(breakCmd)
}