-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathroot.go
More file actions
46 lines (40 loc) · 950 Bytes
/
Copy pathroot.go
File metadata and controls
46 lines (40 loc) · 950 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package cmd
import (
"os"
"path/filepath"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "timetreat",
Version: "0.1.1-dev",
Short: "Treat yourself to some tasty time tracking.",
Long: ` _ _ _ _
| | (_) | | | |
| |_ _ _ __ ___ ___| |_ _ __ ___ __ _| |_
| __| | '_ ' _ \ / _ \ __| '__/ _ \/ _' | __|
| |_| | | | | | | __/ |_| | | __/ (_| | |_
\__|_|_| |_| |_|\___|\__|_| \___|\__,_|\__|
`,
}
func Execute() {
err := rootCmd.Execute()
if err != nil {
os.Exit(1)
}
}
func init() {
GlobalConfig.LogFile = getLogFilePath()
}
func getLogFilePath() string {
if env := os.Getenv("TIMETREAT_LOG"); env != "" {
if filepath.IsAbs(env) {
return env
} else {
formattedStringsStyled.PrintfError("log file path must be absolute: %s", env)
os.Exit(1)
}
}
home, err := os.UserHomeDir()
CheckErr(err)
return home + "/timetreat.log"
}