mirror of
https://github.com/passbolt/go-passbolt-cli.git
synced 2025-09-13 14:59:09 +00:00
add doc command
This commit is contained in:
parent
03852b0bca
commit
08cb902aad
5 changed files with 112 additions and 2 deletions
34
cmd/doc.go
Normal file
34
cmd/doc.go
Normal file
|
@ -0,0 +1,34 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/cobra/doc"
|
||||
)
|
||||
|
||||
// configureCmd represents the configure command
|
||||
var genDocCmd = &cobra.Command{
|
||||
Use: "gendoc",
|
||||
Hidden: true,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
docType, err := cmd.Flags().GetString("type")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cmd.DisableAutoGenTag = true
|
||||
switch docType {
|
||||
case "markdown":
|
||||
return doc.GenMarkdownTree(rootCmd, "doc")
|
||||
case "man":
|
||||
return doc.GenManTree(rootCmd, nil, "man")
|
||||
default:
|
||||
return fmt.Errorf("Unknown type: %v", docType)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(genDocCmd)
|
||||
genDocCmd.Flags().StringP("type", "t", "markdown", "what to generate, markdown or man")
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue