summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorNikolaus Gotsche <n@softwarefools.com>2018-09-15 03:31:52 +0200
committerNikolaus Gotsche <n@softwarefools.com>2018-09-15 03:31:52 +0200
commitb67ad525147b8d219ff3508674dec3b25a3f62f0 (patch)
tree2684d4bb2dce753a9d90b892735f45360e5413b0 /main.go
parent4fa9a4e986d457b406236fc62a5955a2275b83a9 (diff)
Makefile added, everything streamlined0.2.10.2.0
Diffstat (limited to 'main.go')
-rw-r--r--main.go198
1 files changed, 30 insertions, 168 deletions
diff --git a/main.go b/main.go
index d74bde5..2974eb5 100644
--- a/main.go
+++ b/main.go
@@ -3,7 +3,7 @@ package main
import (
"fmt"
"flag"
- "path/filepath"
+ _ "path/filepath"
_ "log"
//"bufio"
"os"
@@ -12,11 +12,15 @@ import (
"github.com/fatih/color"
)
+var (
+ version string
+ compdate string
+)
//var svar string
-var starttime,stoptime string
-var projectid, edittaskid, editprojectid, editcustomerid int
-var deltask,delbill int
-var addcustomer bool
+var starttime,stoptime,filename string
+//var projectid, edittaskid, editprojectid, editcustomerid int
+//var deltask,delbill int
+//var addcustomer bool
var newproject, newtask, stoptask, allproj, allbills, runinter, test, newconfig bool
var billcount int
@@ -40,6 +44,7 @@ func title(frame bool) {
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")
}
}
@@ -47,92 +52,20 @@ func title(frame bool) {
func init() {
- //red := color.New(color.FgRed).SprintFunc
- //green := color.New(color.FgGreen)
- //yellow := color.New(color.FgYellow)
- //use of package color without selectorcyan := color.New(color.FgCyan)
- //boldGreen := color.New(color.FgGreen, color.Bold)
- //boldRed := color.New(color.FgRed, color.Bold)
+
+ //flag.StringVar(&svar, "svar", "bar", "A String Var")
flag.BoolVar(&test,
"test",
false,
"Test Some Functions")
-
-
- flag.BoolVar(&newconfig,
- "config",
- false,
- "View and Edit Configuration")
- flag.BoolVar(&addcustomer,
- "add",
- false,
- "Adds a new Customer")
- flag.BoolVar(&allproj,
- "all",
- false,
- "Show all Projects")
- flag.BoolVar(&allbills,
- "allbills",
- false,
- "Show all Bills")
- flag.IntVar(&billcount,
- "showbills",
- 0,
- "How Many of Previous bills should be shown")
- flag.BoolVar(&runinter,
- "run",
- false,
- "Run in Interactive mode")
- flag.BoolVar(&newtask,
- "startnow",
- false,
- "Start a new Task in current project")
- flag.IntVar(&delbill,
- "deletebill",
- 0,
- "Specify which Bill to delete")
- flag.IntVar(&deltask,
- "deletetask",
- 0,
- "Specify which Task to delete")
- flag.IntVar(&edittaskid,
- "edittask",
- 0,
- "Specify which Task to edit")
- flag.IntVar(&editprojectid,
- "editproject",
- 0,
- "Specify which project to edit")
- flag.IntVar(&editcustomerid,
- "editcustomer",
- 0,
- "Specify which customer to edit")
- flag.IntVar(&projectid,
- "project",
- 0,
- "Specify which project to track")
- flag.BoolVar(&stoptask,
- "stopnow",
- false,
- "Stop the currently open task")
- flag.StringVar(&starttime,
- "start",
- "now",
- "Start a new Task in current project\nFormat: 'YYYY-MM-DD HH:MM' or 'HH:MM'")
- flag.StringVar(&stoptime,
- "stop",
- "now",
- "Stop to Track the current Task\nFormat: 'YYYY-MM-DD HH:MM' or 'HH:MM'")
- flag.BoolVar(&newproject,
- "new",
- false,
- "Create a new project")
- //flag.StringVar(&svar, "svar", "bar", "A String Var")
-
+ 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 0.1.4:\n %s [Options] [Database]\n\n [Database] - must have .db fileextension, only one allowed\n\n [Options]:\n", os.Args[0],os.Args[0])
+ fmt.Fprintf(os.Stderr, "Usage of %s Version %s (%s):\n %s [Options] args\n\n Arguments: use 'help' to get the full list \n\n [Options]:\n", os.Args[0],version,compdate,os.Args[0])
flag.PrintDefaults()
}
@@ -149,18 +82,18 @@ func stdOut() {
}
func main() {
- boldRed := color.New(color.FgRed, color.Bold).SprintFunc()
+ //boldRed := color.New(color.FgRed, color.Bold).SprintFunc()
//fmt.Println("Laboravi Started")
dbname := "./.mytimes.db"
- if flag.NFlag() > 0 {
+// if flag.NFlag() > 0 {
title(true)
- }else{
- title(false)
+// }else{
+// title(false)
//fmt.Println("Laboravi Started")
- }
+// }
initConf()
dbname = config.Database
- if len(flag.Args())>0 {
+/* if len(flag.Args())>0 {
aar := flag.Args()
var uar []string
@@ -181,13 +114,10 @@ func main() {
fmt.Println("Unknown Commands: ",boldRed(uar))
}
}
-
- initDB(dbname)
- getLastProject()
- //getProjects()
- getOpenTask()
+*/
if test {
+ fmt.Println(getGitTag())
fmt.Println("Nothing to test")
//tmpltest()
//newBill(1)
@@ -197,79 +127,11 @@ func main() {
os.Exit(0)
}
- if allproj {
- allProjects()
- }
-
- if allbills {
- showLastBills(0)
- } else if (billcount>0) {
- showLastBills(billcount)
- }
+ initDB(dbname)
+ getLastProject()
+ //getProjects()
+ getOpenTask()
- if runinter {
- interact()
- }
- if newconfig {
- editConf()
- }
- if newproject {
- newProject()
- os.Exit(0)
- } else if addcustomer {
- addCustomer()
- os.Exit(0)
- } else if newtask {
- showLastProject()
- newTask(projectid)
- stdOut()
- //showLastProject()
- //getClosedTasks(0)
- //showOpenTask()
- //os.Exit(0)
- } else if stoptask {
- closeTask()
- stdOut()
- //showLastProject()
- //getClosedTasks(0)
- //showOpenTask()
- } else if (starttime != "now") {
- showLastProject()
- newTaskTime(projectid,starttime)
- os.Exit(0)
- } else if (stoptime != "now") {
- closeTaskTime(stoptime)
- stdOut()
- //showLastProject()
- //getClosedTasks(0)
- //showOpenTask()
- } else if (delbill>0) {
- deleteBill(delbill)
- } else if (deltask>0) {
- deleteTask(deltask)
- } else if (edittaskid>0) {
- editTask(edittaskid)
- } else if (editprojectid>0) {
- editProject(editprojectid)
- } else if (editcustomerid>0) {
- editCustomer(editcustomerid)
- } else if (projectid>0) {
- setProject(projectid)
- stdOut()
- //showLastProject()
- //getClosedTasks(0)
- //showOpenTask()
- } else {
- //showLastProject()
- //getClosedTasks(0)
- //showOpenTask()
- stdOut()
- }
+ interact()
- //fmt.Println("Start Act:",actstart)
- //fmt.Println("Stop Act:",actstop)
- //fmt.Println("Project:",projectid)
- //fmt.Println("New Project:",newproject)
- //fmt.Println("svar:",svar)
- //fmt.Println("Unknown Commands: ",flag.Args())
}