Add offline-first task-master TUI with tickets, board lists, and undo.
Charm-based CLI with JSON persistence, status/list filters, external editor editing, command-history undo/redo, and glamour markdown without AutoStyle OSC hangs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
package ticket
|
||||
|
||||
// BoardList is a project-scoped view/filter over tickets by status.
|
||||
type BoardList string
|
||||
|
||||
const (
|
||||
BoardAll BoardList = "all"
|
||||
BoardBacklog BoardList = "backlog"
|
||||
BoardInProgress BoardList = "in_progress"
|
||||
BoardDone BoardList = "done"
|
||||
)
|
||||
|
||||
// AllBoardLists is the ordered picker list.
|
||||
var AllBoardLists = []BoardList{BoardAll, BoardBacklog, BoardInProgress, BoardDone}
|
||||
|
||||
// Label returns a display name for the board list.
|
||||
func (b BoardList) Label() string {
|
||||
switch b {
|
||||
case BoardAll:
|
||||
return "All"
|
||||
case BoardBacklog:
|
||||
return "Backlog"
|
||||
case BoardInProgress:
|
||||
return "In Progress"
|
||||
case BoardDone:
|
||||
return "Done"
|
||||
default:
|
||||
return string(b)
|
||||
}
|
||||
}
|
||||
|
||||
// Index returns the position in AllBoardLists.
|
||||
func (b BoardList) Index() int {
|
||||
for i, bl := range AllBoardLists {
|
||||
if bl == b {
|
||||
return i
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// ParseBoardList validates a board list id; invalid values become BoardAll.
|
||||
func ParseBoardList(s string) BoardList {
|
||||
b := BoardList(s)
|
||||
switch b {
|
||||
case BoardAll, BoardBacklog, BoardInProgress, BoardDone:
|
||||
return b
|
||||
default:
|
||||
return BoardAll
|
||||
}
|
||||
}
|
||||
|
||||
// Matches reports whether a ticket belongs on this board list.
|
||||
func (b BoardList) Matches(status Status) bool {
|
||||
switch b {
|
||||
case BoardAll:
|
||||
return true
|
||||
case BoardBacklog:
|
||||
return status == StatusTodo
|
||||
case BoardInProgress:
|
||||
return status == StatusInProgress
|
||||
case BoardDone:
|
||||
return status == StatusDone
|
||||
default:
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
// DefaultStatus is the status used when creating a ticket on this list.
|
||||
func (b BoardList) DefaultStatus() Status {
|
||||
switch b {
|
||||
case BoardInProgress:
|
||||
return StatusInProgress
|
||||
case BoardDone:
|
||||
return StatusDone
|
||||
default:
|
||||
return StatusTodo
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user