package cmd import ( "fmt" "os" "git.jnss.me/joakim/jadedepo/internal/engine" "github.com/spf13/cobra" ) var ( listCmd = &cobra.Command{ Use: "list", Short: "List all notes in the depository", Run: listNotes, } ) func init() { rootCmd.AddCommand(listCmd) } func listNotes(cmd *cobra.Command, args []string) { jd, err := engine.GetInstance() if err != nil { fmt.Fprintf(os.Stderr, "Error: %v\n", err) os.Exit(1) } notes, err := jd.ListAllNotes() if err != nil { fmt.Fprintf(os.Stderr, "Error listing notes: %v\n", err) os.Exit(1) } if len(notes) == 0 { fmt.Println("No notes found in depository") return } fmt.Printf("Found %d note(s):\n\n", len(notes)) for _, note := range notes { fmt.Printf(" %s\n", note.Title) fmt.Printf(" Path: %s\n", note.Path) if len(note.Tags) > 0 { fmt.Printf(" Tags: %v\n", note.Tags) } fmt.Println() } }