summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorNikolaus Gotsche <n@softwarefools.com>2018-10-19 12:30:46 +0200
committerNikolaus Gotsche <n@softwarefools.com>2018-10-19 12:30:46 +0200
commit404386194b9492b29b03d4e1e65558c545a70b51 (patch)
tree159b8f61939d7163ba4d63c2cd89ecda4579b1b7 /main.go
parentae396b0399a9ee4ec8aee4879f0eb36bc7aeb7e8 (diff)
Trys in Auto-Documentation
Diffstat (limited to 'main.go')
-rw-r--r--main.go266
1 files changed, 143 insertions, 123 deletions
diff --git a/main.go b/main.go
index fdc84e7..eda3469 100644
--- a/main.go
+++ b/main.go
@@ -1,22 +1,27 @@
+// Copyright 2018 n@gotsche.at
+// All Rights Reserved
+
+// Laboravi - Timetracker and Bill generator
+//
+// I came, I worked, I Billed
package main
import (
- "fmt"
- //"flag"
- "path/filepath"
- _ "log"
- //"bufio"
- "os"
- //"strings"
- _ "os/exec"
- "github.com/fatih/color"
- "github.com/pborman/getopt/v2"
+ "fmt"
+ _ "log"
+ "os"
+ "path/filepath"
+ //"strings"
+ "github.com/fatih/color"
+ "github.com/pborman/getopt/v2"
+ _ "os/exec"
)
var (
- version string
- compdate string
+ version string
+ compdate string
)
+
//var svar string
//var starttime,stoptime,filename string
//var projectid int
@@ -26,133 +31,148 @@ var (
//var newproject, newtask, stoptask, allproj, allbills, runinter, test, newconfig bool
//var billcount int
-var test,help bool
+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()*/
-}
+ 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 := "___"
-
- 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")
- }
+ 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")
+ }
}
+// stdOut shows the standard output the user can determine
+// the state of Laboravi immediately.
func stdOut() {
- showLastProject()
- getClosedTasks(0)
- showOpenTask()
+ showLastProject()
+ getClosedTasks(0)
+ showOpenTask()
}
func main() {
- //boldRed := color.New(color.FgRed, color.Bold).SprintFunc()
- //fmt.Println("Laboravi Started")
- getopt.Parse()
- interArgs = getopt.Args()
-
- //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...)
-
- }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("Nothing to test")
- //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()
-
- fmt.Println("Laboravi finietur...")
+ //boldRed := color.New(color.FgRed, color.Bold).SprintFunc()
+ //fmt.Println("Laboravi Started")
+ getopt.Parse()
+ interArgs = getopt.Args()
+
+ //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...)
+
+ } 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()
+
+ fmt.Println("Laboravi finietur...")
}