SetTips sets the tips for a command (stored as JSON in Annotations).
(cmd *cobra.Command, tips []string)
| 13 | |
| 14 | // SetTips sets the tips for a command (stored as JSON in Annotations). |
| 15 | func SetTips(cmd *cobra.Command, tips []string) { |
| 16 | if len(tips) == 0 { |
| 17 | return |
| 18 | } |
| 19 | if cmd.Annotations == nil { |
| 20 | cmd.Annotations = map[string]string{} |
| 21 | } |
| 22 | data, _ := json.Marshal(tips) |
| 23 | cmd.Annotations[tipsAnnotationKey] = string(data) |
| 24 | } |
| 25 | |
| 26 | // AddTips appends tips to a command (merges with existing). |
| 27 | func AddTips(cmd *cobra.Command, tips ...string) { |
no outgoing calls