forked from redhat-developer/odo
/
preference.go
43 lines (34 loc) · 1.4 KB
/
preference.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package preference
import (
"fmt"
"github.com/openshift/odo/pkg/odo/util"
"github.com/openshift/odo/pkg/preference"
"github.com/spf13/cobra"
ktemplates "k8s.io/kubernetes/pkg/kubectl/cmd/templates"
)
// RecommendedCommandName is the recommended preference command name
const RecommendedCommandName = "preference"
var preferenceLongDesc = ktemplates.LongDesc(`Modifies Odo specific configuration settings within the global preference file.
%[1]s
`)
// NewCmdPreference implements the utils config odo command
func NewCmdPreference(name, fullName string) *cobra.Command {
preferenceViewCmd := NewCmdView(viewCommandName, util.GetFullName(fullName, viewCommandName))
preferenceSetCmd := NewCmdSet(setCommandName, util.GetFullName(fullName, setCommandName))
preferenceUnsetCmd := NewCmdUnset(unsetCommandName, util.GetFullName(fullName, unsetCommandName))
preferenceCmd := &cobra.Command{
Use: name,
Short: "Modifies preference settings",
Long: fmt.Sprintf(preferenceLongDesc, preference.FormatSupportedParameters()),
Example: fmt.Sprintf("%s\n%s\n%s",
preferenceViewCmd.Example,
preferenceSetCmd.Example,
preferenceUnsetCmd.Example,
),
}
preferenceCmd.AddCommand(preferenceViewCmd, preferenceSetCmd)
preferenceCmd.AddCommand(preferenceUnsetCmd)
preferenceCmd.SetUsageTemplate(util.CmdUsageTemplate)
preferenceCmd.Annotations = map[string]string{"command": "other"}
return preferenceCmd
}