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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
|
// Copyright 2018 n@gotsche.at
// All Rights Reserved
// Laboravi - Timetracker and Bill generator
//
// I came, I worked, I charged
package main
import (
"fmt"
_ "log"
"os"
"path/filepath"
//"strings"
"github.com/fatih/color"
"github.com/pborman/getopt/v2"
_ "os/exec"
)
var (
version string
compdate string
compyear 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 test, help bool
var filename string
var interArgs []string
//var red, green, yellow, cyan color
//var boldRed, boldGreen color
func init() {
filename = "none"
//interArgs = removeStringFromArray(os.Args[1:],"-file",1)
getopt.FlagLong(&test, "test", 't', "Test some new Functions")
getopt.FlagLong(&help, "help", 'h', "Show Program Usage")
getopt.FlagLong(&filename, "file", 'f', "Load different DB than in config")
//flag.StringVar(&svar, "svar", "bar", "A String Var")
/* flag.BoolVar(&test,
"test",
false,
"Test Some Functions")
flag.StringVar(&filename,
"file",
"none",
"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])
fmt.Fprintf(os.Stdout, "Usage of %s Version %s (%s):\n %s [Options] <Commands>\n\nOptions:\n", os.Args[0],version,compdate,os.Args[0])
flag.PrintDefaults()
interArgs = append([]string{"help"},interArgs...)
}
//flag.SetOutput(os.Stdout)
flag.Parse()*/
}
// title prints the colored Laboravi Logo.
//
// Argument decides if a Frame shpuld be drawn around it.
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 := "___"
compyear = compdate[len(compdate)-4:]
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.Printf("(c) 2018-%v - n@softwarefools.com\n\n",compyear)
}
}
// stdOut shows the standard output the user can determine
// the state of Laboravi immediately.
func stdOut() {
//showLastProject()
//getClosedTasks(0)
//showOpenTask()
showStatus(false)
}
func main() {
//boldRed := color.New(color.FgRed, color.Bold).SprintFunc()
//fmt.Println("Laboravi Started")
getopt.Parse()
interArgs = getopt.Args()
loadall := true
//fmt.Println(interArgs)
dbname := "./.mytimes.db"
if len(interArgs) > 0 {
title(false)
} else {
title(true)
}
if help {
fmt.Printf("Usage of %s Version %s:\n Use Commands as Parameters\n If Commands or flags other than -f were passed %s exits after execution of command.\n\n", os.Args[0], version, os.Args[0])
getopt.Usage()
interArgs = append([]string{"help"}, interArgs...)
loadall = false
} else if test {
//fmt.Println(Round(12.55,0.5),Round(12.55,0.1),Round(12.55,1),Round(12.55,5))
//fmt.Println(getGitTag())
//multichoice("Fuckoff")
fmt.Println(mli,"halllllllooooo",li,li,li)
fmt.Println(nli)
fmt.Println(sli,"Something something Something")
fmt.Println(nli,"And some more text lalala")
fmt.Println(fli,"And some End")
fmt.Println("Nothing to test")
fmt.Println(frame("HEADLINE",true))
fmt.Println(sli,"Something something Something")
fmt.Println(nli,"And some more text lalala")
fmt.Println(nli)
fmt.Println(sli,"More Something Something")
fmt.Println(nli,"And even some more text lalala")
fmt.Println(nli)
fmt.Println(frame("FOOTER",false))
//tmpltest()
//newBill(1)
//c := []int{2,3}
//a,b := getUnfinishedList(c)
//fmt.Println(a,b)
os.Exit(0)
} else {
initConf()
}
haveone := false
if filename != "none" {
if haveone {
fmt.Println("Only One DB Allowed! Will ignore", filename)
} else {
haveone = true
dbname = filename
if filepath.Ext(filename) != ".db" || filepath.Ext(filename) != ".sql" {
fmt.Println("Please consider to use a file extension like .db or .sql \n like ~/.<name>.db")
}
}
} else {
dbname = config.Database
}
if !help {
initDB(dbname)
pausetask = getPauseTask()
getLastProject()
getOpenTask()
}
interact(loadall)
fmt.Println("Laboravi finietur...")
}
|