refactor: convert inbox command to default alias
This commit is contained in:
15
cmd/list.go
15
cmd/list.go
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
var lAssignee string
|
||||
var lTags []string
|
||||
var lMention string
|
||||
|
||||
var listCmd = &cobra.Command{
|
||||
Use: "list", Short: "List nodes",
|
||||
@@ -22,7 +23,18 @@ var listCmd = &cobra.Command{
|
||||
return
|
||||
}
|
||||
svc := service.NewSQLiteNodeService(d.DB, cfg.GetUser())
|
||||
if nodes, err := svc.List(service.WithTags(lTags...), service.WithAssignee(lAssignee)); err == nil {
|
||||
opts := []service.ListOption{}
|
||||
if len(lTags) > 0 {
|
||||
opts = append(opts, service.WithTags(lTags...))
|
||||
}
|
||||
if lAssignee != "" {
|
||||
opts = append(opts, service.WithAssignee(lAssignee))
|
||||
}
|
||||
if lMention != "" {
|
||||
opts = append(opts, service.WithMentions(lMention))
|
||||
}
|
||||
|
||||
if nodes, err := svc.List(opts...); err == nil {
|
||||
output.PrintNodes(cmd.OutOrStdout(), nodes, jsonFlag)
|
||||
} else {
|
||||
fmt.Fprintf(os.Stderr, "err: %v\n", err)
|
||||
@@ -36,4 +48,5 @@ func init() {
|
||||
f := listCmd.Flags()
|
||||
f.StringVar(&lAssignee, "assignee", "", "")
|
||||
f.StringArrayVar(&lTags, "tag", nil, "")
|
||||
f.StringVar(&lMention, "mention", "", "")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user