feat: adding list_by command
This commit is contained in:
28
commands/list_tasks_by.go
Normal file
28
commands/list_tasks_by.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package commands
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gotask-cli/models"
|
||||
"gotask-cli/utils"
|
||||
)
|
||||
|
||||
func ListTasksBy(status string, backlog []models.Task) {
|
||||
var backlogToDisplay []models.Task
|
||||
var statusID models.Status
|
||||
for i, v := range models.StatusName {
|
||||
if v == status {
|
||||
statusID = i
|
||||
}
|
||||
}
|
||||
for _, v := range backlog {
|
||||
if v.Status == models.Status(statusID) {
|
||||
backlogToDisplay = append(backlogToDisplay, v)
|
||||
}
|
||||
}
|
||||
if len(backlogToDisplay) > 0 {
|
||||
utils.PrintTasksAsATable(backlogToDisplay)
|
||||
} else {
|
||||
fmt.Printf("No tasks with the status [%s]", status)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user