|
|
@ -7,7 +7,7 @@ import ( |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
func PrintMenu() { |
|
|
|
func PrintMenu() { |
|
|
|
fmt.Printf("### TODO APP ###\n") |
|
|
|
fmt.Printf("\n\n### TODO APP ###\n") |
|
|
|
fmt.Printf("1: List Todo\n") |
|
|
|
fmt.Printf("1: List Todo\n") |
|
|
|
fmt.Printf("2: Add Todo\n") |
|
|
|
fmt.Printf("2: Add Todo\n") |
|
|
|
fmt.Printf("3: Remove Todo (via index)\n") |
|
|
|
fmt.Printf("3: Remove Todo (via index)\n") |
|
|
@ -51,7 +51,7 @@ func main() { |
|
|
|
fmt.Printf("Which TODO to remove?\n> ") |
|
|
|
fmt.Printf("Which TODO to remove?\n> ") |
|
|
|
|
|
|
|
|
|
|
|
if _, err := fmt.Scanf("%d", &index); err != nil { |
|
|
|
if _, err := fmt.Scanf("%d", &index); err != nil { |
|
|
|
fmt.Printf("Invalid input\n> ") |
|
|
|
fmt.Printf("Which TODO to remove?\n> ") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if err := list.RemoveTodo(index); err != nil { |
|
|
|
if err := list.RemoveTodo(index); err != nil { |
|
|
@ -65,43 +65,4 @@ func main() { |
|
|
|
PrintMenu() |
|
|
|
PrintMenu() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
|
|
list := Todos{} |
|
|
|
|
|
|
|
//todos := []Todo{}
|
|
|
|
|
|
|
|
//list := Todos{todos}
|
|
|
|
|
|
|
|
fmt.Println("Empty list: ") |
|
|
|
|
|
|
|
list.ListTodo() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Println("Adding entries...") |
|
|
|
|
|
|
|
items := []Todo{ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Title: "test", |
|
|
|
|
|
|
|
Content: "Here is some content", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Title: "test1", |
|
|
|
|
|
|
|
Content: "Here is some more content", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
Title: "test2", |
|
|
|
|
|
|
|
Content: "Here is even MORE content", |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Add the items for testing
|
|
|
|
|
|
|
|
for item := range items { |
|
|
|
|
|
|
|
list.AddTodo(items[item]) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Println("Listing...") |
|
|
|
|
|
|
|
list.ListTodo() |
|
|
|
|
|
|
|
fmt.Println("Listing again...") |
|
|
|
|
|
|
|
list.ListTodo() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fmt.Println("Removing item2 via index 1") |
|
|
|
|
|
|
|
list.RemoveTodo(1) |
|
|
|
|
|
|
|
fmt.Println("Listing again...") |
|
|
|
|
|
|
|
list.ListTodo() |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|