Re-add zet links

This commit is contained in:
Oliver Davies 2025-09-30 07:00:00 +01:00
parent df9fa52c21
commit 035d575f0e
5 changed files with 51 additions and 4 deletions

40
cmd/links.go Normal file
View file

@ -0,0 +1,40 @@
package cmd
import (
"fmt"
"os"
"strings"
"github.com/spf13/cobra"
"code.oliverdavies.uk/opdavies/cmd-zet/internal/lib"
)
var linksCmd = &cobra.Command{
Use: "links",
Aliases: []string{"l"},
Short: "TODO",
Long: `zet links QUERY`,
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 1 {
fmt.Println("No query")
os.Exit(1)
}
zets := lib.SearchZets(args[0])
lines := lib.ParseZetList(zets)
for _, line := range lines {
line = strings.TrimSpace(line)
parts := strings.SplitN(line, " ", 2)
id := parts[0]
title := parts[1]
fmt.Printf("* link:../%s/index.adoc[%s]\n", id, title)
}
},
}