From 6ff013dd2afe9547fb403de56b265112661bf6be Mon Sep 17 00:00:00 2001 From: Elias Kohout Date: Sun, 29 Mar 2026 19:56:15 +0200 Subject: [PATCH] refactor: convert inbox command to default alias --- README.md | 9 +++------ cmd/inbox.go | 30 ------------------------------ cmd/list.go | 15 ++++++++++++++- service/fileconfig.go | 1 + 4 files changed, 18 insertions(+), 37 deletions(-) delete mode 100644 cmd/inbox.go diff --git a/README.md b/README.md index 382a7b1..3f5fc0e 100644 --- a/README.md +++ b/README.md @@ -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:** diff --git a/cmd/inbox.go b/cmd/inbox.go deleted file mode 100644 index b999e1c..0000000 --- a/cmd/inbox.go +++ /dev/null @@ -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) -} diff --git a/cmd/list.go b/cmd/list.go index 3ea0172..e313bed 100644 --- a/cmd/list.go +++ b/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", "", "") } diff --git a/service/fileconfig.go b/service/fileconfig.go index 6514c65..ee5edae 100644 --- a/service/fileconfig.go +++ b/service/fileconfig.go @@ -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) {