Skip to content

Commit

Permalink
Add SilenceUsage for all commands to not to print usage on error
Browse files Browse the repository at this point in the history
  • Loading branch information
soltysh committed Apr 23, 2021
1 parent 62f758b commit e2b9e9c
Show file tree
Hide file tree
Showing 18 changed files with 54 additions and 36 deletions.
5 changes: 3 additions & 2 deletions cmd/cluster/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ type Options struct {

func NewCreateCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "cluster",
Short: "Creates basic functional HostedCluster resources",
Use: "cluster",
Short: "Creates basic functional HostedCluster resources",
SilenceUsage: true,
}

var releaseImage string
Expand Down
5 changes: 3 additions & 2 deletions cmd/cluster/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ type DestroyOptions struct {

func NewDestroyCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "cluster",
Short: "Destroys a HostedCluster and its associated infrastructure.",
Use: "cluster",
Short: "Destroys a HostedCluster and its associated infrastructure.",
SilenceUsage: true,
}

opts := DestroyOptions{
Expand Down
5 changes: 3 additions & 2 deletions cmd/cluster/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ type DumpOptions struct {

func NewDumpCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "cluster",
Short: "Creates basic functional HostedCluster resources",
Use: "cluster",
Short: "Creates basic functional HostedCluster resources",
SilenceUsage: true,
}

opts := &DumpOptions{
Expand Down
5 changes: 3 additions & 2 deletions cmd/create/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import (

func NewCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "create",
Short: "Commands for creating HyperShift resources",
Use: "create",
Short: "Commands for creating HyperShift resources",
SilenceUsage: true,
}

cmd.AddCommand(cluster.NewCreateCommand())
Expand Down
5 changes: 3 additions & 2 deletions cmd/destroy/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ import (

func NewCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "destroy",
Short: "Commands for destroying HyperShift resources",
Use: "destroy",
Short: "Commands for destroying HyperShift resources",
SilenceUsage: true,
}

cmd.AddCommand(infra.NewDestroyCommand())
Expand Down
5 changes: 3 additions & 2 deletions cmd/dump/dump.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (

func NewCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "dump",
Short: "Commands for dumping resources for debugging",
Use: "dump",
Short: "Commands for dumping resources for debugging",
SilenceUsage: true,
}

cmd.AddCommand(cluster.NewDumpCommand())
Expand Down
5 changes: 3 additions & 2 deletions cmd/infra/aws/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,9 @@ const (

func NewCreateCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "aws",
Short: "Creates AWS infrastructure resources for a cluster",
Use: "aws",
Short: "Creates AWS infrastructure resources for a cluster",
SilenceUsage: true,
}

opts := CreateInfraOptions{
Expand Down
5 changes: 3 additions & 2 deletions cmd/infra/aws/create_iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,9 @@ type CreateIAMOutput struct {

func NewCreateIAMCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "aws",
Short: "Creates AWS instance profile for workers",
Use: "aws",
Short: "Creates AWS instance profile for workers",
SilenceUsage: true,
}

opts := CreateIAMOptions{
Expand Down
5 changes: 3 additions & 2 deletions cmd/infra/aws/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ type DestroyInfraOptions struct {

func NewDestroyCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "aws",
Short: "Destroys AWS infrastructure resources for a cluster",
Use: "aws",
Short: "Destroys AWS infrastructure resources for a cluster",
SilenceUsage: true,
}

opts := DestroyInfraOptions{
Expand Down
5 changes: 3 additions & 2 deletions cmd/infra/aws/destroy_iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ type DestroyIAMOptions struct {

func NewDestroyIAMCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "aws",
Short: "Destroys AWS instance profile for workers",
Use: "aws",
Short: "Destroys AWS instance profile for workers",
SilenceUsage: true,
}

opts := DestroyIAMOptions{
Expand Down
5 changes: 3 additions & 2 deletions cmd/infra/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (

func NewCreateCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "infra",
Short: "Commands for creating HyperShift infra resources",
Use: "infra",
Short: "Commands for creating HyperShift infra resources",
SilenceUsage: true,
}

cmd.AddCommand(aws.NewCreateCommand())
Expand Down
5 changes: 3 additions & 2 deletions cmd/infra/create_iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (

func NewCreateIAMCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "iam",
Short: "Commands for creating HyperShift IAM resources",
Use: "iam",
Short: "Commands for creating HyperShift IAM resources",
SilenceUsage: true,
}

cmd.AddCommand(aws.NewCreateIAMCommand())
Expand Down
5 changes: 3 additions & 2 deletions cmd/infra/destroy.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (

func NewDestroyCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "infra",
Short: "Commands for destroying HyperShift infra resources",
Use: "infra",
Short: "Commands for destroying HyperShift infra resources",
SilenceUsage: true,
}

cmd.AddCommand(aws.NewDestroyCommand())
Expand Down
5 changes: 3 additions & 2 deletions cmd/infra/destroy_iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (

func NewDestroyIAMCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "iam",
Short: "Commands for destroying HyperShift IAM resources",
Use: "iam",
Short: "Commands for destroying HyperShift IAM resources",
SilenceUsage: true,
}

cmd.AddCommand(aws.NewDestroyIAMCommand())
Expand Down
5 changes: 3 additions & 2 deletions cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ type Options struct {

func NewCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "install",
Short: "Installs the HyperShift operator",
Use: "install",
Short: "Installs the HyperShift operator",
SilenceUsage: true,
}

var opts Options
Expand Down
7 changes: 4 additions & 3 deletions cmd/kubeconfig/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ of the HostedCluster itself.
// from HostedCluster resources.
func NewCreateCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "kubeconfig",
Short: "Creates a combined kubeconfig from hostedcluster resources",
Long: description,
Use: "kubeconfig",
Short: "Creates a combined kubeconfig from hostedcluster resources",
Long: description,
SilenceUsage: true,
}

cmd.RunE = func(cmd *cobra.Command, args []string) error {
Expand Down
5 changes: 3 additions & 2 deletions cmd/nodepool/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ type CreateNodePoolOptions struct {

func NewCreateCommand() *cobra.Command {
cmd := &cobra.Command{
Use: "nodepool",
Short: "Create a HyperShift NodePool",
Use: "nodepool",
Short: "Create a HyperShift NodePool",
SilenceUsage: true,
}

opts := CreateNodePoolOptions{
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ import (

func main() {
cmd := &cobra.Command{
Use: "hypershift",
Use: "hypershift",
SilenceUsage: true,
Run: func(cmd *cobra.Command, args []string) {
cmd.Help()
os.Exit(1)
Expand Down

0 comments on commit e2b9e9c

Please sign in to comment.