From 943b49caa3a9546c86ab3ab63b8ec16de0463d29 Mon Sep 17 00:00:00 2001 From: NiloCK Date: Sat, 10 Jan 2026 10:34:44 -0400 Subject: [PATCH 1/2] add handling for create, list cli commands... toward agent SKILL.md integration ? --- main.go | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++ tui/config.go | 8 +++++++ tui/tui.go | 16 ++++++------- 3 files changed, 79 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index fcd36ab..af12379 100644 --- a/main.go +++ b/main.go @@ -5,12 +5,44 @@ import ( "fmt" "os" "runtime" + "strings" "github.com/nilock/tuido/tui" + "github.com/nilock/tuido/tuido" "github.com/nilock/tuido/utils" ) func main() { + if len(os.Args) > 1 { + switch os.Args[1] { + case "list": + listCmd := flag.NewFlagSet("list", flag.ExitOnError) + maxItems := listCmd.Int("max", 0, "maximum number of items to display") + listCmd.Parse(os.Args[2:]) + + path := "." + if listCmd.NArg() > 0 { + path = listCmd.Arg(0) + } + + runList(path, *maxItems) + return + + case "create", "add": + text := strings.Join(os.Args[2:], " ") + if text == "" { + fmt.Println("Usage: tuido create [text]") + os.Exit(1) + } + runCreate(text) + return + + case "version", "-version", "--version": + showVersionInfo() + return + } + } + var showVersion = flag.Bool("version", false, "show version and platform information") flag.Parse() @@ -22,6 +54,37 @@ func main() { tui.Run() } +func runList(path string, max int) { + files := tui.GetFiles(path, tui.GetConfigExtensions()) + items := []*tuido.Item{} + for _, f := range files { + items = append(items, tui.GetItems(f)...) + } + + tui.SortItems(items) + + count := len(items) + if max > 0 && max < count { + count = max + } + + for i := 0; i < count; i++ { + item := items[i] + fmt.Printf("%s\n", item.String()) + } +} + +func runCreate(text string) { + writeTo := tui.GetConfigWriteTo() + item := tuido.New(writeTo, -1, "") + err := item.SetText(text) + if err != nil { + fmt.Printf("Error creating item: %v\n", err) + os.Exit(1) + } + fmt.Printf("Created: %s\n", item.String()) +} + func showVersionInfo() { version := utils.Version() goos := runtime.GOOS diff --git a/tui/config.go b/tui/config.go index cccb28f..cbb2e14 100644 --- a/tui/config.go +++ b/tui/config.go @@ -105,3 +105,11 @@ func parseConfig(file *os.File) config { return cfg } + +func GetConfigExtensions() []string { + return runConfig.extensions +} + +func GetConfigWriteTo() string { + return runConfig.writeto +} diff --git a/tui/tui.go b/tui/tui.go index d75cb9c..f4154cd 100644 --- a/tui/tui.go +++ b/tui/tui.go @@ -46,7 +46,7 @@ func Run() { os.Exit(1) } if wtStat.IsDir() { - writeDirFiles := getFiles(runConfig.writeto, runConfig.extensions) + writeDirFiles := GetFiles(runConfig.writeto, runConfig.extensions) for _, f := range writeDirFiles { files[f] = struct{}{} } @@ -54,7 +54,7 @@ func Run() { // [ ] replace with subdir check #active=2022-05-26 #zzz=2 if wrkdirStr != runConfig.writeto { - wdFiles := getFiles(wrkdirStr, runConfig.extensions) + wdFiles := GetFiles(wrkdirStr, runConfig.extensions) for _, f := range wdFiles { files[f] = struct{}{} } @@ -62,10 +62,10 @@ func Run() { items := []*tuido.Item{} for f := range files { - items = append(items, getItems(f)...) + items = append(items, GetItems(f)...) } - sortItems(items) + SortItems(items) tui := newTUI(items, runConfig) tui.houseKeeping() @@ -313,7 +313,7 @@ func (t *tui) populateRenderSelection() { // Only sort if no filter is active - preserve fuzzy search ranking if len(t.filter.Value()) == 0 { - sortItems(t.renderSelection) + SortItems(t.renderSelection) } // ensure the previous selection value is still in range @@ -448,7 +448,7 @@ func itemHasTag(itemTags []tuido.Tag, filter tuido.Tag) bool { func (t tui) Init() tea.Cmd { return tick() } -func getItems(file string) []*tuido.Item { +func GetItems(file string) []*tuido.Item { items := []*tuido.Item{} if f, err := os.Open(file); err != nil { @@ -471,7 +471,7 @@ func getItems(file string) []*tuido.Item { } } -func getFiles(wd string, extensions []string) []string { +func GetFiles(wd string, extensions []string) []string { files := []string{} @@ -501,7 +501,7 @@ func getFiles(wd string, extensions []string) []string { return files } -func sortItems(items []*tuido.Item) { +func SortItems(items []*tuido.Item) { sort.SliceStable(items, func(i, j int) bool { if items[i].Importance() > items[j].Importance() { return true From 55e692e90a6db4cdce504ca66f878e50bd4c9e8f Mon Sep 17 00:00:00 2001 From: NiloCK Date: Thu, 28 May 2026 10:46:55 -0300 Subject: [PATCH 2/2] list active items by default --- main.go | 58 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 49 insertions(+), 9 deletions(-) diff --git a/main.go b/main.go index af12379..84123d1 100644 --- a/main.go +++ b/main.go @@ -18,6 +18,10 @@ func main() { case "list": listCmd := flag.NewFlagSet("list", flag.ExitOnError) maxItems := listCmd.Int("max", 0, "maximum number of items to display") + inclSnoozed := listCmd.Bool("z", false, "include snoozed items") + listCmd.BoolVar(inclSnoozed, "zzz", false, "include snoozed items") + inclAll := listCmd.Bool("a", false, "include snoozed and completed/cancelled items") + listCmd.BoolVar(inclAll, "all", false, "include snoozed and completed/cancelled items") listCmd.Parse(os.Args[2:]) path := "." @@ -25,13 +29,13 @@ func main() { path = listCmd.Arg(0) } - runList(path, *maxItems) + runList(path, *maxItems, *inclSnoozed || *inclAll, *inclAll) return case "create", "add": text := strings.Join(os.Args[2:], " ") if text == "" { - fmt.Println("Usage: tuido create [text]") + fmt.Fprintln(os.Stderr, "Usage: tuido create ") os.Exit(1) } runCreate(text) @@ -40,10 +44,15 @@ func main() { case "version", "-version", "--version": showVersionInfo() return + + case "help", "-help", "--help", "-h": + printHelp() + return } } var showVersion = flag.Bool("version", false, "show version and platform information") + flag.Usage = printHelp flag.Parse() if *showVersion { @@ -54,23 +63,34 @@ func main() { tui.Run() } -func runList(path string, max int) { +func runList(path string, max int, inclSnoozed bool, inclDone bool) { files := tui.GetFiles(path, tui.GetConfigExtensions()) - items := []*tuido.Item{} + all := []*tuido.Item{} for _, f := range files { - items = append(items, tui.GetItems(f)...) + all = append(all, tui.GetItems(f)...) } - tui.SortItems(items) + tui.SortItems(all) + + filtered := all[:0] + for _, item := range all { + s := item.Satus() + if !inclDone && (s == tuido.Checked || s == tuido.Obsolete) { + continue + } + if !inclSnoozed && !item.Active() { + continue + } + filtered = append(filtered, item) + } - count := len(items) + count := len(filtered) if max > 0 && max < count { count = max } for i := 0; i < count; i++ { - item := items[i] - fmt.Printf("%s\n", item.String()) + fmt.Printf("%s\n", filtered[i].String()) } } @@ -85,6 +105,26 @@ func runCreate(text string) { fmt.Printf("Created: %s\n", item.String()) } +func printHelp() { + fmt.Print(`Usage: tuido [command] [options] + +Without a command, opens the interactive TUI. + +Commands: + list [options] [path] List open/in-progress items (default path: .) + -z, --zzz Include snoozed items + -a, --all Include snoozed and completed/cancelled items + --max N Limit output to N items + create Create a new todo item + add Alias for create + version Show version and platform information + help Show this help + +Flags: + -version Show version and platform information +`) +} + func showVersionInfo() { version := utils.Version() goos := runtime.GOOS