...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package main
16
17 import (
18 "fmt"
19 "os"
20
21 "github.com/sigstore/cosign/v2/cmd/cosign/cli"
22 "github.com/sigstore/cosign/v2/cmd/cosign/cli/templates"
23 errors "github.com/sigstore/cosign/v2/cmd/cosign/errors"
24 "github.com/spf13/cobra"
25 "github.com/spf13/cobra/doc"
26 )
27
28 func main() {
29 var dir string
30 root := &cobra.Command{
31 Use: "gendoc",
32 Short: "Generate cosign's help docs",
33 SilenceUsage: true,
34 Args: cobra.NoArgs,
35 RunE: func(*cobra.Command, []string) error {
36 err := errors.GenerateExitCodeDocs(dir)
37 if err != nil {
38 fmt.Println(err)
39 os.Exit(1)
40 }
41 return doc.GenMarkdownTree(cli.New(), dir)
42 },
43 }
44 root.Flags().StringVarP(&dir, "dir", "d", "doc", "Path to directory in which to generate docs")
45
46 templates.SetCustomUsageFunc(root)
47
48 if err := root.Execute(); err != nil {
49 fmt.Println(err)
50 os.Exit(1)
51 }
52 }
53
View as plain text