84 lines
1.9 KiB
Go
84 lines
1.9 KiB
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"fmt"
|
||
|
"strconv"
|
||
|
|
||
|
"git.bullercodeworks.com/brian/gask"
|
||
|
)
|
||
|
|
||
|
type CliTask struct {
|
||
|
Id string // This tasks full id (alpha-numeric)
|
||
|
ParentId string
|
||
|
Description string
|
||
|
IsDone bool
|
||
|
Depth int
|
||
|
Subtasks []CliTask // The Task's subtasks
|
||
|
|
||
|
dbTask *gask.GaskTask // The DB Backing for this task
|
||
|
}
|
||
|
|
||
|
func NewCliTask(gt *gask.GaskTask) *CliTask {
|
||
|
ret := new(CliTask)
|
||
|
ret.Description = gt.Description
|
||
|
ret.IsDone = gt.IsDone
|
||
|
ret.Depth = gt.Depth
|
||
|
for i := 0; i < len(gt.Subtasks); i++ {
|
||
|
ret.Subtasks = append(ret.Subtasks, *NewCliTask(>.Subtasks[i]))
|
||
|
}
|
||
|
ret.dbTask = gt
|
||
|
return ret
|
||
|
}
|
||
|
|
||
|
// GetTask takes the id argument and returns the task for the id
|
||
|
// e.g. 'b10' would return the 11th (0-indexed) task from list 'b'
|
||
|
func (a *App) GetTask(id string) (*gask.GaskTask, error) {
|
||
|
var err error
|
||
|
var lst *gask.GaskList
|
||
|
if lst, err = a.GetList(id); err != nil {
|
||
|
return nil, err
|
||
|
}
|
||
|
var ret *gask.GaskTask
|
||
|
_ = lst
|
||
|
return ret, errors.New("Couldn't find task")
|
||
|
}
|
||
|
|
||
|
// AddTask adds a task
|
||
|
func (a *App) AddTask(args []string) error {
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// CompleteTasks marks a task as complete
|
||
|
func (a *App) CompleteTask(args []string) error {
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// PrintTasks lists tasks in the db
|
||
|
func (a *App) PrintTasks(args []string) error {
|
||
|
var err error
|
||
|
if len(args) > 0 {
|
||
|
if err = a.PrintList(args[0]); err != nil {
|
||
|
return err
|
||
|
}
|
||
|
} else {
|
||
|
// Just list everything
|
||
|
for lstId := 0; lstId < a.db.Lists.Length(); lstId++ {
|
||
|
var tskCnt int
|
||
|
lstAlphaId := indexToAlpha(lstId)
|
||
|
fmt.Println("@" + lstAlphaId + " " + a.db.Lists.Get(lstId).Name)
|
||
|
for i := 0; i < a.db.Lists.Get(lstId).Tasks.Length(); i++ {
|
||
|
tskId := "@" + lstAlphaId + strconv.Itoa(tskCnt)
|
||
|
fmt.Println(taskToAppString(tskId, a.db.Lists.Get(lstId).Tasks.Get(i)))
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
// printTask prints the tId-th task in list lId with all of it's detail
|
||
|
func (a *App) PrintTask(lId string, tId int) error {
|
||
|
return nil
|
||
|
}
|