52160345bf
Complete implementation of note management CLI with all core features: Commands: - add: Create new notes in $EDITOR with auto-generated filenames - list: Display all notes with titles, paths, and tags - search: Full-text search via ripgrep, tag-based filtering - tags: List all tags with occurrence counts - edit: Fuzzy search and edit notes by title - rm: Move notes to trash with confirmation prompt Features: - Automatic depository structure initialization (.jade/trash/) - Configurable tag prefix (default '+') - Parse title from first # heading (filename fallback) - Extract tags anywhere in content - Parse both [[wiki-links]] and [markdown](links) - Trash system with timestamps to prevent conflicts Technical: - Global config at ~/.config/jade/config.yml - Per-depository settings support - Ripgrep integration for fast search - $EDITOR integration for note editing - Comprehensive README with usage examples
51 lines
900 B
Go
51 lines
900 B
Go
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()
|
|
}
|
|
}
|