/
get.go
46 lines (42 loc) · 1.21 KB
/
get.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package cmd
import (
"fmt"
"regexp"
"strings"
"github.com/charmbracelet/log"
"github.com/drewstinnett/taskpoet/taskpoet"
"github.com/spf13/cobra"
)
// newGetCmd is the new get command
func newGetCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "active",
Short: "Get Active tasks, waiting to be completed",
Aliases: []string{"g", "a", "get"},
Version: version,
Long: `Get Active Tasks
`,
Run: func(cmd *cobra.Command, args []string) {
tableOpts := mustTableOptsWithCmd(cmd, args)
tableOpts.Prefix = "/active"
tableOpts.Columns = []string{"ID", "Age", "Due", "Description", "Urgency"}
tableOpts.SortBy = taskpoet.ByUrgency{}
tableOpts.Filters = []taskpoet.Filter{
taskpoet.FilterHidden,
taskpoet.FilterRegex,
}
var re *regexp.Regexp
if len(args) > 0 {
tableOpts.FilterParams.Regex = regexp.MustCompile(fmt.Sprintf("(?i)%v", strings.Join(args, " ")))
log.Debug("Showing tasks that match", "regex", re)
} else {
tableOpts.FilterParams.Regex = regexp.MustCompile(".*")
}
// table := poetC.TaskTable("/active", *fp, taskpoet.FilterHidden, taskpoet.FilterRegex)
table := poetC.TaskTable(*tableOpts)
fmt.Print(table)
},
}
bindTableOpts(cmd)
return cmd
}