From 8cf8ad7e24d57810d893c483e5071e76c2cbab47 Mon Sep 17 00:00:00 2001 From: Andrew Merenbach Date: Wed, 6 Jun 2018 16:32:30 -0700 Subject: [PATCH] Tweak flags for import/export, thanks @jessesuen (#268) --- cmd/argocd-util/main.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cmd/argocd-util/main.go b/cmd/argocd-util/main.go index be1db06296..650dcea3ff 100644 --- a/cmd/argocd-util/main.go +++ b/cmd/argocd-util/main.go @@ -169,12 +169,16 @@ func NewGenDexConfigCommand() *cobra.Command { func NewImportCommand() *cobra.Command { var ( clientConfig clientcmd.ClientConfig - in string ) var command = cobra.Command{ - Use: "import", - Short: "Import Argo CD data", + Use: "import SOURCE", + Short: "Import Argo CD data from stdin (specify `-') or a file", RunE: func(c *cobra.Command, args []string) error { + if len(args) != 1 { + c.HelpFunc()(c, args) + os.Exit(1) + } + var ( input []byte err error @@ -183,7 +187,8 @@ func NewImportCommand() *cobra.Command { newClusters []*v1alpha1.Cluster newApps []*v1alpha1.Application ) - if in == "-" { + + if in := args[0]; in == "-" { input, err = ioutil.ReadAll(os.Stdin) errors.CheckError(err) } else { @@ -241,7 +246,6 @@ func NewImportCommand() *cobra.Command { } clientConfig = cli.AddKubectlFlagsToCmd(&command) - command.Flags().StringVarP(&in, "in", "i", "-", "Input from the specified file instead of stdin") return &command } @@ -254,7 +258,7 @@ func NewExportCommand() *cobra.Command { ) var command = cobra.Command{ Use: "export", - Short: "Export all Argo CD data", + Short: "Export all Argo CD data to stdout (default) or a file", RunE: func(c *cobra.Command, args []string) error { config, err := clientConfig.ClientConfig() errors.CheckError(err)