Re-add zet links
This commit is contained in:
parent
df9fa52c21
commit
035d575f0e
5 changed files with 51 additions and 4 deletions
|
@ -3,6 +3,7 @@ package cmd
|
|||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
|
@ -23,6 +24,8 @@ var findCmd = &cobra.Command{
|
|||
|
||||
zets := lib.SearchZets(args[0])
|
||||
|
||||
lib.ParseZetList(zets)
|
||||
result := lib.ParseZetList(zets)
|
||||
|
||||
fmt.Println(strings.Join(result, "\n"))
|
||||
},
|
||||
}
|
||||
|
|
40
cmd/links.go
Normal file
40
cmd/links.go
Normal 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)
|
||||
}
|
||||
},
|
||||
}
|
|
@ -29,6 +29,7 @@ func init() {
|
|||
rootCmd.AddCommand(createCmd)
|
||||
rootCmd.AddCommand(editCmd)
|
||||
rootCmd.AddCommand(findCmd)
|
||||
rootCmd.AddCommand(linksCmd)
|
||||
rootCmd.AddCommand(titlesCmd)
|
||||
rootCmd.AddCommand(viewCmd)
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
|
||||
"code.oliverdavies.uk/opdavies/cmd-zet/internal/lib"
|
||||
|
@ -14,6 +17,8 @@ var titlesCmd = &cobra.Command{
|
|||
Run: func(cmd *cobra.Command, args []string) {
|
||||
zets := lib.GetAllZets()
|
||||
|
||||
lib.ParseZetList(zets)
|
||||
result := lib.ParseZetList(zets)
|
||||
|
||||
fmt.Println(strings.Join(result, "\n"))
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue