1
0
Fork 0
mirror of https://github.com/Luzifer/worktime.git synced 2024-10-18 08:04:22 +00:00
worktime/cmd/overtime.go
2016-09-24 14:59:16 +02:00

39 lines
980 B
Go

package cmd
import (
"fmt"
"time"
"github.com/Luzifer/worktime/schema"
"github.com/spf13/cobra"
)
// overtimeCmd represents the overtime command
var overtimeCmd = &cobra.Command{
Use: "overtime",
Short: "Shows total overtime over all time",
RunE: func(cmd *cobra.Command, args []string) error {
overtime, err := schema.GetOvertime(cfg.couchDB, time.Time{})
if err != nil {
return err
}
fmt.Printf("Total overtime: %s\n", time.Duration(overtime.Value*float64(time.Hour)))
return nil
},
}
func init() {
RootCmd.AddCommand(overtimeCmd)
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// overtimeCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// overtimeCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}