forked from LaconicNetwork/kompose
Merge pull request #279 from cab105/bash-completion
Added flag definitions for kompose #37
This commit is contained in:
commit
83c7a824dc
@ -28,6 +28,12 @@ import (
|
|||||||
// Hook for erroring and exit out on warning
|
// Hook for erroring and exit out on warning
|
||||||
type errorOnWarningHook struct{}
|
type errorOnWarningHook struct{}
|
||||||
|
|
||||||
|
// array consisting of our common conversion flags that will get passed along
|
||||||
|
// for the autocomplete aspect
|
||||||
|
var (
|
||||||
|
commonConvertFlagsList = []string{"out", "replicas", "yaml", "stdout", "emptyvols"}
|
||||||
|
)
|
||||||
|
|
||||||
func (errorOnWarningHook) Levels() []logrus.Level {
|
func (errorOnWarningHook) Levels() []logrus.Level {
|
||||||
return []logrus.Level{logrus.WarnLevel}
|
return []logrus.Level{logrus.WarnLevel}
|
||||||
}
|
}
|
||||||
@ -75,6 +81,17 @@ func ConvertCommandDummy() cli.Command {
|
|||||||
return command
|
return command
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Generate the Bash completion flag taking the common flags plus whatever is
|
||||||
|
// passed into the function to correspond to the primary command specific args
|
||||||
|
func generateBashCompletion(args []string) {
|
||||||
|
commonArgs := []string{"bundle", "file", "suppress-warnings", "verbose", "error-on-warning", "provider"}
|
||||||
|
flags := append(commonArgs, args...)
|
||||||
|
|
||||||
|
for _,f := range flags {
|
||||||
|
fmt.Printf("--%s\n", f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ConvertKubernetesCommand defines the kompose convert subcommand for Kubernetes provider
|
// ConvertKubernetesCommand defines the kompose convert subcommand for Kubernetes provider
|
||||||
func ConvertKubernetesCommand() cli.Command {
|
func ConvertKubernetesCommand() cli.Command {
|
||||||
command := cli.Command{
|
command := cli.Command{
|
||||||
@ -83,6 +100,10 @@ func ConvertKubernetesCommand() cli.Command {
|
|||||||
Action: func(c *cli.Context) {
|
Action: func(c *cli.Context) {
|
||||||
app.Convert(c)
|
app.Convert(c)
|
||||||
},
|
},
|
||||||
|
BashComplete: func(c *cli.Context) {
|
||||||
|
flags := []string{"chart", "deployment", "daemonset", "replicationcontroller"}
|
||||||
|
generateBashCompletion(append(flags, commonConvertFlagsList...))
|
||||||
|
},
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "chart,c",
|
Name: "chart,c",
|
||||||
@ -114,6 +135,10 @@ func ConvertOpenShiftCommand() cli.Command {
|
|||||||
Action: func(c *cli.Context) {
|
Action: func(c *cli.Context) {
|
||||||
app.Convert(c)
|
app.Convert(c)
|
||||||
},
|
},
|
||||||
|
BashComplete: func(c *cli.Context) {
|
||||||
|
flags := []string{"deploymentconfig"}
|
||||||
|
generateBashCompletion(append(flags, commonConvertFlagsList...))
|
||||||
|
},
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "deploymentconfig,dc",
|
Name: "deploymentconfig,dc",
|
||||||
@ -160,6 +185,10 @@ func UpCommand() cli.Command {
|
|||||||
Action: func(c *cli.Context) {
|
Action: func(c *cli.Context) {
|
||||||
app.Up(c)
|
app.Up(c)
|
||||||
},
|
},
|
||||||
|
BashComplete: func(c *cli.Context) {
|
||||||
|
flags := []string{"emptyvols"}
|
||||||
|
generateBashCompletion(flags)
|
||||||
|
},
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "emptyvols",
|
Name: "emptyvols",
|
||||||
@ -177,6 +206,10 @@ func DownCommand() cli.Command {
|
|||||||
Action: func(c *cli.Context) {
|
Action: func(c *cli.Context) {
|
||||||
app.Down(c)
|
app.Down(c)
|
||||||
},
|
},
|
||||||
|
BashComplete: func(c *cli.Context) {
|
||||||
|
flags := []string{"emptyvols"}
|
||||||
|
generateBashCompletion(flags)
|
||||||
|
},
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
cli.BoolFlag{
|
cli.BoolFlag{
|
||||||
Name: "emptyvols",
|
Name: "emptyvols",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user