Skip to content
This repository was archived by the owner on Sep 9, 2022. It is now read-only.

Commit aa97054

Browse files
committed
start building secman help command handlers
1 parent e0c04a4 commit aa97054

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

cmd/secman/help-topic.go

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
package secman
2+
3+
import (
4+
"github.com/spf13/cobra"
5+
)
6+
7+
var HelpTopics = map[string]map[string]string{}
8+
9+
func NewHelpTopic(topic string) *cobra.Command {
10+
cmd := &cobra.Command{
11+
Use: topic,
12+
Short: HelpTopics[topic]["short"],
13+
Long: HelpTopics[topic]["long"],
14+
Hidden: true,
15+
Annotations: map[string]string{
16+
"markdown:generate": "true",
17+
"markdown:basename": "secman_help_" + topic,
18+
},
19+
}
20+
21+
cmd.SetHelpFunc(helpTopicHelpFunc)
22+
cmd.SetUsageFunc(helpTopicUsageFunc)
23+
24+
return cmd
25+
}
26+
27+
func helpTopicHelpFunc(command *cobra.Command, args []string) {
28+
command.Print(command.Long)
29+
}
30+
31+
func helpTopicUsageFunc(command *cobra.Command) error {
32+
command.Printf("Usage: secman help %s", command.Use)
33+
return nil
34+
}

0 commit comments

Comments
 (0)