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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
package main
import (
"fmt"
"flag"
_ "path/filepath"
_ "log"
//"bufio"
"os"
//"strings"
_ "os/exec"
"github.com/fatih/color"
)
var (
version string
compdate string
)
//var svar string
var starttime,stoptime,filename string
//var projectid int
//, edittaskid, editprojectid, editcustomerid int
//var deltask,delbill int
//var addcustomer bool
var newproject, newtask, stoptask, allproj, allbills, runinter, test, newconfig bool
var billcount int
//var red, green, yellow, cyan color
//var boldRed, boldGreen color
func title(frame bool) {
bR := color.New(color.FgRed, color.Bold).SprintFunc()
bHiR := color.New(color.FgHiRed, color.Bold).SprintFunc()
bHiY := color.New(color.FgHiYellow, color.Bold).SprintFunc()
bHiG := color.New(color.FgHiGreen, color.Bold).SprintFunc()
bHiC := color.New(color.FgHiCyan, color.Bold).SprintFunc()
bHiB := color.New(color.FgHiBlue, color.Bold).SprintFunc()
bHiM := color.New(color.FgHiMagenta, color.Bold).SprintFunc()
bM := color.New(color.FgMagenta, color.Bold).SprintFunc()
line := "___"
if frame {
fmt.Printf("%s%s%s%s%s%s%s%s\n\n",bR(line),bHiR(line),bHiY(line),bHiG(line),bHiC(line),bHiB(line),bHiM(line),bM(line))
}
fmt.Println(" ",bR("L"),bHiR("A"),bHiY("B"),bHiG("O"),bHiC("R"),bHiB("A"),bHiM("V"),bM("I"))
if frame {
fmt.Printf("%s%s%s%s%s%s%s%s\n",bR(line),bHiR(line),bHiY(line),bHiG(line),bHiC(line),bHiB(line),bHiM(line),bM(line))
fmt.Printf("Version %s (%s)\n",version,compdate)
fmt.Println("(c) 2018 - n@gotsche.at\n")
}
}
func init() {
//flag.StringVar(&svar, "svar", "bar", "A String Var")
flag.BoolVar(&test,
"test",
false,
"Test Some Functions")
flag.StringVar(&filename,
"file",
"~/.mytimes.db",
"Open a different Database than specified in Configuration")
// CUSTOMIZE USAGE
flag.Usage = func() {
fmt.Fprintf(os.Stderr, "Usage of %s Version %s (%s):\n %s [Options] <Commands>\n\nOptions:\n", os.Args[0],version,compdate,os.Args[0])
flag.PrintDefaults()
}
flag.Parse()
}
func stdOut() {
showLastProject()
getClosedTasks(0)
showOpenTask()
}
func main() {
//boldRed := color.New(color.FgRed, color.Bold).SprintFunc()
//fmt.Println("Laboravi Started")
dbname := "./.mytimes.db"
// if flag.NFlag() > 0 {
title(true)
// }else{
// title(false)
//fmt.Println("Laboravi Started")
// }
initConf()
dbname = config.Database
/* if len(flag.Args())>0 {
aar := flag.Args()
var uar []string
haveone := false
for _,car := range aar {
if filepath.Ext(car) == ".db" {
if haveone {
fmt.Println("Only One DB Allowed! Will ignore",car)
} else {
dbname=car
haveone=true
}
}else{
uar = append(uar,car)
}
}
if len(uar)>0 {
fmt.Println("Unknown Commands: ",boldRed(uar))
}
}
*/
if test {
fmt.Println(getGitTag())
fmt.Println("Nothing to test")
//tmpltest()
//newBill(1)
//c := []int{2,3}
//a,b := getUnfinishedList(c)
//fmt.Println(a,b)
os.Exit(0)
}
initDB(dbname)
getLastProject()
//getProjects()
getOpenTask()
interact()
}
|