Skip to content

Commit

Permalink
Merge pull request #362 from weaveworks/fix-usage
Browse files Browse the repository at this point in the history
Fix usage text for all commands
  • Loading branch information
errordeveloper authored Dec 21, 2018
2 parents 5eb6e8a + 3a7056a commit 697d939
Show file tree
Hide file tree
Showing 12 changed files with 58 additions and 43 deletions.
10 changes: 5 additions & 5 deletions cmd/eksctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ func main() {
}

func addCommands(g *cmdutils.Grouping) {
rootCmd.AddCommand(versionCmd())
rootCmd.AddCommand(versionCmd(g))
rootCmd.AddCommand(create.Command(g))
rootCmd.AddCommand(delete.Command())
rootCmd.AddCommand(get.Command())
rootCmd.AddCommand(scale.Command())
rootCmd.AddCommand(utils.Command())
rootCmd.AddCommand(delete.Command(g))
rootCmd.AddCommand(get.Command(g))
rootCmd.AddCommand(scale.Command(g))
rootCmd.AddCommand(utils.Command(g))
rootCmd.AddCommand(completion.Command(rootCmd))
}
4 changes: 2 additions & 2 deletions cmd/eksctl/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import (
"github.com/kris-nova/logger"
"github.com/spf13/cobra"

"github.com/weaveworks/eksctl/pkg/ctl/cmdutils"
"github.com/weaveworks/eksctl/pkg/version"
)

func versionCmd() *cobra.Command {
func versionCmd(_ *cmdutils.Grouping) *cobra.Command {
return &cobra.Command{
Use: "version",
Short: "Output the version of eksctl",
Run: func(_ *cobra.Command, _ []string) {

logger.Info("%#v", version.Get())
},
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/ctl/delete/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
"github.com/weaveworks/eksctl/pkg/utils/kubeconfig"
)

func deleteClusterCmd() *cobra.Command {
func deleteClusterCmd(g *cmdutils.Grouping) *cobra.Command {
p := &api.ProviderConfig{}
cfg := api.NewClusterConfig()

Expand All @@ -29,7 +29,7 @@ func deleteClusterCmd() *cobra.Command {
},
}

group := &cmdutils.NamedFlagSetGroup{}
group := g.New(cmd)

group.InFlagSet("General", func(fs *pflag.FlagSet) {
fs.StringVarP(&cfg.Metadata.Name, "name", "n", "", "EKS cluster name (required)")
Expand Down
5 changes: 3 additions & 2 deletions pkg/ctl/delete/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package delete
import (
"github.com/kris-nova/logger"
"github.com/spf13/cobra"
"github.com/weaveworks/eksctl/pkg/ctl/cmdutils"
)

var (
waitDelete bool
)

// Command will create the `delete` commands
func Command() *cobra.Command {
func Command(g *cmdutils.Grouping) *cobra.Command {
cmd := &cobra.Command{
Use: "delete",
Short: "Delete resource(s)",
Expand All @@ -21,7 +22,7 @@ func Command() *cobra.Command {
},
}

cmd.AddCommand(deleteClusterCmd())
cmd.AddCommand(deleteClusterCmd(g))

return cmd
}
19 changes: 11 additions & 8 deletions pkg/ctl/get/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import (

"github.com/kris-nova/logger"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/weaveworks/eksctl/pkg/ctl/cmdutils"
"github.com/weaveworks/eksctl/pkg/eks"
"github.com/weaveworks/eksctl/pkg/eks/api"
)

var listAllRegions bool

func getClusterCmd() *cobra.Command {
func getClusterCmd(g *cmdutils.Grouping) *cobra.Command {
p := &api.ProviderConfig{}
cfg := api.NewClusterConfig()

Expand All @@ -29,16 +30,18 @@ func getClusterCmd() *cobra.Command {
},
}

fs := cmd.Flags()
group := g.New(cmd)

fs.StringVarP(&cfg.Metadata.Name, "name", "n", "", "EKS cluster name")
fs.BoolVarP(&listAllRegions, "all-regions", "A", false, "List clusters across all supported regions")
fs.IntVar(&chunkSize, "chunk-size", defaultChunkSize, "Return large lists in chunks rather than all at once. Pass 0 to disable.")
group.InFlagSet("General", func(fs *pflag.FlagSet) {
fs.StringVarP(&cfg.Metadata.Name, "name", "n", "", "EKS cluster name")
fs.BoolVarP(&listAllRegions, "all-regions", "A", false, "List clusters across all supported regions")
fs.IntVar(&chunkSize, "chunk-size", defaultChunkSize, "Return large lists in chunks rather than all at once. Pass 0 to disable.")

fs.StringVarP(&p.Region, "region", "r", "", "AWS region")
fs.StringVarP(&p.Profile, "profile", "p", "", "AWS credentials profile to use (overrides the AWS_PROFILE environment variable)")
fs.StringVarP(&p.Region, "region", "r", "", "AWS region")
fs.StringVarP(&p.Profile, "profile", "p", "", "AWS credentials profile to use (overrides the AWS_PROFILE environment variable)")

fs.StringVarP(&output, "output", "o", "table", "Specifies the output format. Choose from table,json,yaml. Defaults to table.")
fs.StringVarP(&output, "output", "o", "table", "Specifies the output format. Choose from table,json,yaml. Defaults to table.")
})

return cmd
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/ctl/get/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package get
import (
"github.com/kris-nova/logger"
"github.com/spf13/cobra"
"github.com/weaveworks/eksctl/pkg/ctl/cmdutils"
)

const (
Expand All @@ -15,7 +16,7 @@ var (
)

// Command will create the `get` commands
func Command() *cobra.Command {
func Command(g *cmdutils.Grouping) *cobra.Command {
cmd := &cobra.Command{
Use: "get",
Short: "Get resource(s)",
Expand All @@ -26,7 +27,7 @@ func Command() *cobra.Command {
},
}

cmd.AddCommand(getClusterCmd())
cmd.AddCommand(getClusterCmd(g))

return cmd
}
18 changes: 11 additions & 7 deletions pkg/ctl/scale/nodegroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import (

"github.com/kris-nova/logger"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/weaveworks/eksctl/pkg/ctl/cmdutils"
"github.com/weaveworks/eksctl/pkg/eks"
"github.com/weaveworks/eksctl/pkg/eks/api"
)

func scaleNodeGroupCmd() *cobra.Command {
func scaleNodeGroupCmd(g *cmdutils.Grouping) *cobra.Command {
p := &api.ProviderConfig{}
cfg := api.NewClusterConfig()
ng := cfg.NewNodeGroup()
Expand All @@ -26,16 +28,18 @@ func scaleNodeGroupCmd() *cobra.Command {
},
}

fs := cmd.Flags()
group := g.New(cmd)

fs.StringVarP(&cfg.Metadata.Name, "name", "n", "", "EKS cluster name")
group.InFlagSet("General", func(fs *pflag.FlagSet) {
fs.StringVarP(&cfg.Metadata.Name, "name", "n", "", "EKS cluster name")

fs.IntVarP(&ng.DesiredCapacity, "nodes", "N", -1, "total number of nodes (scale to this number)")
fs.IntVarP(&ng.DesiredCapacity, "nodes", "N", -1, "total number of nodes (scale to this number)")

fs.StringVarP(&p.Region, "region", "r", "", "AWS region")
fs.StringVarP(&p.Profile, "profile", "p", "", "AWS creditials profile to use (overrides the AWS_PROFILE environment variable)")
fs.StringVarP(&p.Region, "region", "r", "", "AWS region")
fs.StringVarP(&p.Profile, "profile", "p", "", "AWS creditials profile to use (overrides the AWS_PROFILE environment variable)")

fs.DurationVar(&p.WaitTimeout, "timeout", api.DefaultWaitTimeout, "max wait time in any polling operations")
fs.DurationVar(&p.WaitTimeout, "timeout", api.DefaultWaitTimeout, "max wait time in any polling operations")
})

return cmd
}
Expand Down
5 changes: 3 additions & 2 deletions pkg/ctl/scale/scale.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package scale
import (
"github.com/kris-nova/logger"
"github.com/spf13/cobra"
"github.com/weaveworks/eksctl/pkg/ctl/cmdutils"
)

// Command will create the `scale` commands
func Command() *cobra.Command {
func Command(g *cmdutils.Grouping) *cobra.Command {
cmd := &cobra.Command{
Use: "scale",
Short: "Scale resources(s)",
Expand All @@ -17,7 +18,7 @@ func Command() *cobra.Command {
},
}

cmd.AddCommand(scaleNodeGroupCmd())
cmd.AddCommand(scaleNodeGroupCmd(g))

return cmd
}
4 changes: 2 additions & 2 deletions pkg/ctl/utils/describe_stacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ var (
describeStacksEvents bool
)

func describeStacksCmd() *cobra.Command {
func describeStacksCmd(g *cmdutils.Grouping) *cobra.Command {
p := &api.ProviderConfig{}
cfg := api.NewClusterConfig()

Expand All @@ -34,7 +34,7 @@ func describeStacksCmd() *cobra.Command {
},
}

group := &cmdutils.NamedFlagSetGroup{}
group := g.New(cmd)

group.InFlagSet("General", func(fs *pflag.FlagSet) {
fs.StringVarP(&cfg.Metadata.Name, "name", "n", "", "EKS cluster name (required)")
Expand Down
9 changes: 5 additions & 4 deletions pkg/ctl/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ package utils
import (
"github.com/kris-nova/logger"
"github.com/spf13/cobra"
"github.com/weaveworks/eksctl/pkg/ctl/cmdutils"
)

// Command will create the `utils` commands
func Command() *cobra.Command {
func Command(g *cmdutils.Grouping) *cobra.Command {
cmd := &cobra.Command{
Use: "utils",
Short: "Various utils",
Expand All @@ -17,9 +18,9 @@ func Command() *cobra.Command {
},
}

cmd.AddCommand(waitNodesCmd())
cmd.AddCommand(writeKubeconfigCmd())
cmd.AddCommand(describeStacksCmd())
cmd.AddCommand(waitNodesCmd(g))
cmd.AddCommand(writeKubeconfigCmd(g))
cmd.AddCommand(describeStacksCmd(g))

return cmd
}
14 changes: 9 additions & 5 deletions pkg/ctl/utils/wait_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (

"github.com/kris-nova/logger"
"github.com/spf13/cobra"
"github.com/spf13/pflag"
"github.com/weaveworks/eksctl/pkg/ctl/cmdutils"
"github.com/weaveworks/eksctl/pkg/eks"
"github.com/weaveworks/eksctl/pkg/eks/api"
"k8s.io/client-go/kubernetes"
Expand All @@ -14,7 +16,7 @@ import (

var waitNodesKubeconfigPath string

func waitNodesCmd() *cobra.Command {
func waitNodesCmd(g *cmdutils.Grouping) *cobra.Command {
p := &api.ProviderConfig{}
cfg := api.NewClusterConfig()
ng := cfg.NewNodeGroup()
Expand All @@ -30,11 +32,13 @@ func waitNodesCmd() *cobra.Command {
},
}

fs := cmd.Flags()
group := g.New(cmd)

fs.StringVar(&waitNodesKubeconfigPath, "kubeconfig", "kubeconfig", "path to read kubeconfig")
fs.IntVarP(&ng.MinSize, "nodes-min", "m", api.DefaultNodeCount, "minimum number of nodes to wait for")
fs.DurationVar(&p.WaitTimeout, "timeout", api.DefaultWaitTimeout, "how long to wait")
group.InFlagSet("General", func(fs *pflag.FlagSet) {
fs.StringVar(&waitNodesKubeconfigPath, "kubeconfig", "kubeconfig", "path to read kubeconfig")
fs.IntVarP(&ng.MinSize, "nodes-min", "m", api.DefaultNodeCount, "minimum number of nodes to wait for")
fs.DurationVar(&p.WaitTimeout, "timeout", api.DefaultWaitTimeout, "how long to wait")
})

return cmd
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/ctl/utils/write_kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ var (
writeKubeconfigAutoPath bool
)

func writeKubeconfigCmd() *cobra.Command {
func writeKubeconfigCmd(g *cmdutils.Grouping) *cobra.Command {
p := &api.ProviderConfig{}
cfg := api.NewClusterConfig()

Expand All @@ -36,7 +36,7 @@ func writeKubeconfigCmd() *cobra.Command {
},
}

group := &cmdutils.NamedFlagSetGroup{}
group := g.New(cmd)

group.InFlagSet("General", func(fs *pflag.FlagSet) {
fs.StringVarP(&cfg.Metadata.Name, "name", "n", "", "EKS cluster name (required)")
Expand Down

0 comments on commit 697d939

Please sign in to comment.