Skip to content

Commit

Permalink
cmd/timers: Add support for creating a timer
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphexion committed Jul 1, 2021
1 parent 100561a commit 48bb6b5
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions cmd/timers.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ func NewTimerCmd() *cobra.Command {
},
}

startCmd := &cobra.Command{
Use: "start [name of timer]",
Short: "Start a timer",
unpauseCmd := &cobra.Command{
Use: "unpause [name of timer]",
Short: "Unpause a paused timer",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
timer, err := mid.TimerWithName(args[0])
Expand Down Expand Up @@ -90,10 +90,25 @@ func NewTimerCmd() *cobra.Command {
},
}

createCmd := &cobra.Command{
Use: "create [name of project]",
Short: "Create a timer for a project",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
timer, err := mid.CreateTimer(args[0])
if err != nil {
log.Fatal(err)
}

fmt.Printf("Timer created for project %s\n", timer.Project.Name)
},
}

rootCmd.AddCommand(listCmd)
rootCmd.AddCommand(pauseCmd)
rootCmd.AddCommand(startCmd)
rootCmd.AddCommand(unpauseCmd)
rootCmd.AddCommand(noteCmd)
rootCmd.AddCommand(createCmd)

return rootCmd
}

0 comments on commit 48bb6b5

Please sign in to comment.