Refactor
Signed-off-by: Oliver Davies <oliver@oliverdavies.uk>
This commit is contained in:
parent
665ef94ca9
commit
a3202aaff3
17 changed files with 63 additions and 56 deletions
43
internal/cli/links.go
Normal file
43
internal/cli/links.go
Normal file
|
@ -0,0 +1,43 @@
|
|||
package cli
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"code.oliverdavies.uk/opdavies/cmd-zet/internal/zet"
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var linksCmd = &cobra.Command{
|
||||
Use: "links",
|
||||
Aliases: []string{"l"},
|
||||
Short: "TODO",
|
||||
Long: `zet links QUERY`,
|
||||
Run: func(cli *cobra.Command, args []string) {
|
||||
if len(args) < 1 {
|
||||
fmt.Println("No query")
|
||||
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
zets := zet.SearchZets(args[0])
|
||||
|
||||
lines := zet.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)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(linksCmd)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue