zeit/z/rootCmd.go

59 lines
904 B
Go
Raw Permalink Normal View History

2020-10-11 00:58:14 +00:00
package z
import (
"fmt"
"github.com/spf13/cobra"
"github.com/gookit/color"
2020-10-11 00:58:14 +00:00
"os"
)
2020-10-11 20:14:57 +00:00
var database *Database
var begin string
var finish string
var project string
var task string
2020-10-17 12:17:01 +00:00
var notes string
2020-10-11 20:14:57 +00:00
var since string
var until string
2020-10-17 14:50:21 +00:00
var format string
2020-10-11 20:14:57 +00:00
var force bool
2020-10-11 00:58:14 +00:00
var noColors bool
2020-10-15 21:07:36 +00:00
const(
2020-10-16 00:46:52 +00:00
CharTrack = " ▶"
CharFinish = " ■"
CharErase = " ◀"
CharError = " ▲"
CharInfo = " ●"
CharMore = " ◆"
2020-10-15 21:07:36 +00:00
)
2020-10-11 00:58:14 +00:00
var rootCmd = &cobra.Command{
Use: "zeit",
Short: "Command line Zeiterfassung",
Long: `A command line time tracker.`,
}
func Execute() {
if err := rootCmd.Execute(); err != nil {
2020-10-15 21:07:36 +00:00
fmt.Printf("%s %+v\n", CharError, err)
2020-10-15 20:38:25 +00:00
os.Exit(-1)
2020-10-11 00:58:14 +00:00
}
}
func init() {
cobra.OnInitialize(initConfig)
rootCmd.PersistentFlags().BoolVar(&noColors, "no-colors", false, "Do not use colors in output")
2020-10-11 00:58:14 +00:00
}
func initConfig() {
if noColors == true {
color.Disable()
}
2020-10-11 00:58:14 +00:00
}