refactor: convert inbox command to default alias
This commit is contained in:
@@ -112,10 +112,6 @@ Open node content in `$EDITOR`.
|
||||
|
||||
Delete a node. Prompts for confirmation unless `--force`.
|
||||
|
||||
### `ax inbox`
|
||||
|
||||
Show issues in current user's inbox (from @mentions).
|
||||
|
||||
### `ax alias [name] [command] [flags]`
|
||||
|
||||
Manage aliases.
|
||||
@@ -125,7 +121,7 @@ ax alias # list all aliases
|
||||
ax alias mywork "list --tag work" # create alias
|
||||
ax alias mywork # show alias command
|
||||
ax alias mywork "list --tag work2" # update alias
|
||||
ax alias delete mywork # delete alias
|
||||
ax alias del mywork # delete alias
|
||||
```
|
||||
|
||||
**Default aliases:**
|
||||
@@ -134,7 +130,8 @@ ax alias delete mywork # delete alias
|
||||
|-------|---------|-------------|
|
||||
| `mine` | `list --assignee $me --tag _status::open` | Show open tasks assigned to you |
|
||||
| `due` | `list --tag _status::open --tag _due` | Show open tasks with due dates |
|
||||
| `new` | `create $@` | Create a new task |
|
||||
| `new` | `add $@` | Create a new task |
|
||||
| `inbox` | `list --mention $me` | Show your inbox |
|
||||
|
||||
**Alias argument expansion:**
|
||||
|
||||
|
||||
30
cmd/inbox.go
30
cmd/inbox.go
@@ -1,30 +0,0 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"axolotl/db"
|
||||
"axolotl/output"
|
||||
"axolotl/service"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var inboxCmd = &cobra.Command{
|
||||
Use: "inbox", Short: "Show your inbox",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
d, err := db.GetDB()
|
||||
if err != nil {
|
||||
fmt.Fprintln(os.Stderr, err)
|
||||
return
|
||||
}
|
||||
svc := service.NewSQLiteNodeService(d.DB, cfg.GetUser())
|
||||
if nodes, err := svc.List(service.WithMentions(cfg.GetUser())); err == nil {
|
||||
output.PrintNodes(cmd.OutOrStdout(), nodes, jsonFlag)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(inboxCmd)
|
||||
}
|
||||
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", "", "")
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ var defaultAliases = []*Alias{
|
||||
{Name: "mine", Command: "list --assignee $me --tag _status::open", Description: "Show open tasks assigned to you"},
|
||||
{Name: "due", Command: "list --tag _status::open --tag _due", Description: "Show open tasks with due dates"},
|
||||
{Name: "new", Command: "add $@", Description: "Create a new task"},
|
||||
{Name: "inbox", Command: "list --mention $me", Description: "Show your inbox"},
|
||||
}
|
||||
|
||||
func LoadConfig() (Config, error) {
|
||||
|
||||
Reference in New Issue
Block a user