From 4c1961ce7a2bf9e5526d906ba2c317b53ed5f331 Mon Sep 17 00:00:00 2001 From: Nikolaus Gotsche Date: Sun, 14 Jan 2018 05:32:44 +0100 Subject: Verison 0.1 - All Database Operations running --- main.go | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 101 insertions(+), 11 deletions(-) (limited to 'main.go') diff --git a/main.go b/main.go index c54740e..735630d 100644 --- a/main.go +++ b/main.go @@ -3,21 +3,111 @@ package main import ( "fmt" "flag" - "log" + _ "log" + "bufio" "os" "strings" - "os/exec" + _ "os/exec" ) -func main() { - fmt.Println("Hello World") - command := flag.String( - "command", - "", - "The MAin Command") - ignoreErrors := flag.Bool( - "ignore-errors", +var svar string +var starttime,stoptime string +var projectid int +var newproject, newtask, stoptask, allproj bool + +func init() { + + flag.BoolVar(&allproj, + "all", + false, + "Show all Projects") + flag.BoolVar(&newtask, + "start", false, - "Keep running after error if true") + "Start a new Task in current project") + flag.IntVar(&projectid, + "project", + 0, + "Specify which project to track") + flag.BoolVar(&stoptask, + "stop", + false, + "Stop the currently open task") + flag.StringVar(&starttime, + "starttime", + "now", + "") + flag.StringVar(&stoptime, + "stoptime", + "now", + "Stop to Track a Project") + flag.BoolVar(&newproject, + "new", + false, + "Create a new project") + flag.StringVar(&svar, "svar", "bar", "A String Var") + flag.Parse() + +} + +func main() { + fmt.Println("Laboravi Started") + initDB("./.mytimes.db") + getLastProject() + //getProjects() + getOpenTask() + + if allproj { + allProjects() + } + + if newproject { + fmt.Print("Enter Project Name: ") + //var input string + //fmt.Scanln(&input) + in := bufio.NewReader(os.Stdin) + line, err := in.ReadString('\n') + line = strings.TrimSuffix(line, "\n") + checkErr(err) +// fmt.Println(line) + newProject(line) + os.Exit(0) + } else if newtask { + fmt.Print("Specify Task: ") + in := bufio.NewReader(os.Stdin) + line, err := in.ReadString('\n') + line = strings.TrimSuffix(line, "\n") + checkErr(err) + // fmt.Println(line) + newTask(projectid,line) + os.Exit(0) + } else if stoptask { + closeTask() + showLastProject() + getClosedTasks(0) + //fmt.Print("Soon to Come...") + } else if (starttime != "now") { + //fmt.Println("HmmmWTF") + fmt.Print("Soon to Come...") + } else if (stoptime != "now") { + fmt.Print("Soon to Come...") + } else if (projectid>0) { + setProject(projectid) + showLastProject() + getClosedTasks(0) + showOpenTask() + } else { + showLastProject() + getClosedTasks(0) + showOpenTask() + + } + + //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()) } -- cgit v1.2.3