From 0bad1674b54fbea8e72a2ba4399d24f1e8cda562 Mon Sep 17 00:00:00 2001 From: Tuna Date: Fri, 2 Sep 2016 23:55:31 +0700 Subject: [PATCH] make --file as global flag --- cli/app/app.go | 6 +++--- cli/command/command.go | 27 ++++++++------------------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/cli/app/app.go b/cli/app/app.go index e4880b3e..e76ab48d 100644 --- a/cli/app/app.go +++ b/cli/app/app.go @@ -88,7 +88,7 @@ func validateFlags(opt kobject.ConvertOptions, singleOutput bool, dabFile, input // Convert transforms docker compose or dab file to k8s objects func Convert(c *cli.Context) { - inputFile := c.String("file") + inputFile := c.GlobalString("file") dabFile := c.String("bundle") outFile := c.String("out") generateYaml := c.BoolT("yaml") @@ -170,7 +170,7 @@ func Up(c *cli.Context) { } client := client.NewOrDie(clientConfig) - inputFile := c.String("file") + inputFile := c.GlobalString("file") dabFile := c.String("bundle") komposeObject := kobject.KomposeObject{ @@ -220,7 +220,7 @@ func Down(c *cli.Context) { } client := client.NewOrDie(clientConfig) - inputFile := c.String("file") + inputFile := c.GlobalString("file") dabFile := c.String("bundle") komposeObject := kobject.KomposeObject{ diff --git a/cli/command/command.go b/cli/command/command.go index 88b497e1..e5d3f1ed 100644 --- a/cli/command/command.go +++ b/cli/command/command.go @@ -32,12 +32,6 @@ func ConvertCommand() cli.Command { app.Convert(c) }, Flags: []cli.Flag{ - cli.StringFlag{ - Name: "file,f", - Usage: fmt.Sprintf("Specify an alternate compose file (default: %s)", app.DefaultComposeFile), - Value: app.DefaultComposeFile, - EnvVar: "COMPOSE_FILE", - }, cli.StringFlag{ Name: "bundle,dab", Usage: "Specify a Distributed Application Bundle (DAB) file", @@ -94,12 +88,6 @@ func UpCommand() cli.Command { app.Up(c) }, Flags: []cli.Flag{ - cli.StringFlag{ - Name: "file,f", - Usage: fmt.Sprintf("Specify an alternative compose file (default: %s)", app.DefaultComposeFile), - Value: app.DefaultComposeFile, - EnvVar: "COMPOSE_FILE", - }, cli.StringFlag{ Name: "bundle,dab", Usage: "Specify a Distributed Application Bundle (DAB) file", @@ -118,12 +106,6 @@ func DownCommand() cli.Command { app.Down(c) }, Flags: []cli.Flag{ - cli.StringFlag{ - Name: "file,f", - Usage: fmt.Sprintf("Specify an alternative compose file (default: %s)", app.DefaultComposeFile), - Value: app.DefaultComposeFile, - EnvVar: "COMPOSE_FILE", - }, cli.StringFlag{ Name: "bundle,dab", Usage: "Specify a Distributed Application Bundle (DAB) file", @@ -135,5 +117,12 @@ func DownCommand() cli.Command { // CommonFlags defines the flags that are in common for all subcommands. func CommonFlags() []cli.Flag { - return []cli.Flag{} + return []cli.Flag{ + cli.StringFlag{ + Name: "file,f", + Usage: fmt.Sprintf("Specify an alternative compose file (default: %s)", app.DefaultComposeFile), + Value: app.DefaultComposeFile, + EnvVar: "COMPOSE_FILE", + }, + } }