Skip to content
Snippets Groups Projects
timer.go 616 B
Newer Older
  • Learn to ignore specific revisions
  • jrabbit's avatar
    jrabbit committed
    package cmd
    
    import (
    
    	"0xacab.org/jrabbit/adormit/adormit"
    
    jrabbit's avatar
    jrabbit committed
    	"github.com/spf13/cobra"
    	"time"
    )
    
    var Length int
    
    func init() {
    	timerCmd.PersistentFlags().IntVarP(&Length, "length", "l", 60, "length of time in seconds")
    	RootCmd.AddCommand(timerCmd)
    }
    
    var timerCmd = &cobra.Command{
    	Use:   "timer",
    	Short: "run a simple timer",
    	Long:  `runs a timer optionally with `,
    	Run: func(cmd *cobra.Command, args []string) {
    		alarmArgs := []string{"-i", "clock", "Timer over!", "adormit"}
    		t := adormit.Timer{Duration: time.Second * time.Duration(Length), Command: "notify-send", Args: alarmArgs}
    		t.Countdown()
    	},
    }