Skip to content

Commit

Permalink
rename todo.go to main.go
Browse files Browse the repository at this point in the history
use default help command! Don't invent the wheel all over again!
  • Loading branch information
kucukaslan committed Jul 29, 2022
1 parent 68bb360 commit 46692c5
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions todo.go → main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@ func main() {
filename := ".todo.json"

todoList := TodoList{}
readFromFile(todoList, filename)

// Parsing the arguments ...
h := flag.Bool("h", false, "help")
//h := flag.Bool("h", false, "help")
v := flag.Bool("v", false, "version")
l := flag.Bool("l", false, "list all items (un-completed)")
c := flag.Bool("c", false, "list completed items")
a := flag.String("a", "", "add new item")
m := flag.Int("m", -1, "mark as complete")
um := flag.Int("um", -1, "mark as incomplete (unmark)")
d := flag.Int("d", -1, "delete item")

flag.Parse()

if *h {
printHelp()
} else if *v {
readFromFile(todoList, filename)

if *v {
printVersion()
} else if *l {
todoList.printInComplete()
Expand All @@ -49,16 +49,14 @@ func main() {
unMarkItem(&todoList, *um)
} else if *d != -1 {
deleteItem(&todoList, *d)
} else {
//fmt.Println("No arguments given")
printHelp()
}

// Saving the todo list to a file

todoList.writeToFile(filename)
}

/*
func printHelp() {
fmt.Println("-----------------")
fmt.Println("the todo is a command line application that allows you to add, delete, and mark items as complete.")
Expand All @@ -73,7 +71,7 @@ func printHelp() {
fmt.Println("todo -um TODO-ID # mark as incomplete (unmark)")
fmt.Println("todo -d TODO-ID # delete item")
}

*/
func printVersion() {
v := "0.3.0"
date := "2021.11.14"
Expand Down

0 comments on commit 46692c5

Please sign in to comment.