feat(cli): add nib add + nib ls commands

Default command delegation: `nib "..."` routes to `nib add`. Capture
bar parses grammar, creates entities. `nib ls` lists with date
grouping, tag filter, 48h default window. Display glyphs for all
entity types.
This commit is contained in:
2026-05-14 11:17:27 -04:00
parent 51cbf86d77
commit a6fda5d1ee
6 changed files with 312 additions and 2 deletions
+52
View File
@@ -0,0 +1,52 @@
package cmd
import (
"os"
"strings"
"github.com/spf13/cobra"
)
var rootCmd = &cobra.Command{
Use: "nib",
Short: "capture and crystallize notes, todos, and events",
Args: cobra.ArbitraryArgs,
RunE: func(cmd *cobra.Command, args []string) error {
if len(args) == 0 {
return cmd.Help()
}
return runAdd(cmd, args)
},
SilenceUsage: true,
}
func Execute() error {
if len(os.Args) > 1 {
first := os.Args[1]
isFlag := strings.HasPrefix(first, "-") && !strings.Contains(first, " ")
if first != "help" && first != "completion" &&
!isFlag && !isSubcommand(first) {
rootCmd.SetArgs(append([]string{"add", "--"}, os.Args[1:]...))
}
}
return rootCmd.Execute()
}
func isSubcommand(name string) bool {
for _, c := range rootCmd.Commands() {
if c.Name() == name {
return true
}
for _, alias := range c.Aliases {
if alias == name {
return true
}
}
}
return false
}
func init() {
rootCmd.AddCommand(addCmd)
rootCmd.AddCommand(lsCmd)
}