Skip to content

Commit

Permalink
Merge pull request #5416 from twz123/subcommand-show-help-by-default
Browse files Browse the repository at this point in the history
Show help again for non-leaf subcommands
  • Loading branch information
twz123 authored Jan 9, 2025
2 parents 5982a2f + 3a74c39 commit eb5ad6d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 8 deletions.
7 changes: 4 additions & 3 deletions cmd/airgap/airgap.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@ limitations under the License.
package airgap

import (
"github.com/spf13/cobra"

"github.com/k0sproject/k0s/pkg/config"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

func NewAirgapCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "airgap",
Short: "Manage airgap setup",
Args: cobra.NoArgs,
Run: func(*cobra.Command, []string) { /* Enforce arg validation. */ },
RunE: func(*cobra.Command, []string) error { return pflag.ErrHelp }, // Enforce arg validation
}

cmd.AddCommand(NewAirgapListImagesCmd())
Expand Down
3 changes: 2 additions & 1 deletion cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ package config

import (
"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

func NewConfigCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "config",
Short: "Configuration related sub-commands",
Args: cobra.NoArgs,
Run: func(*cobra.Command, []string) { /* Enforce arg validation. */ },
RunE: func(*cobra.Command, []string) error { return pflag.ErrHelp }, // Enforce arg validation
}
cmd.AddCommand(NewCreateCmd())
cmd.AddCommand(NewEditCmd())
Expand Down
3 changes: 2 additions & 1 deletion cmd/etcd/etcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"github.com/k0sproject/k0s/pkg/config"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

func NewEtcdCmd() *cobra.Command {
Expand Down Expand Up @@ -52,7 +53,7 @@ func NewEtcdCmd() *cobra.Command {
}
return nil
},
Run: func(*cobra.Command, []string) { /* Enforce arg validation. */ },
RunE: func(*cobra.Command, []string) error { return pflag.ErrHelp }, // Enforce arg validation
}
cmd.AddCommand(etcdLeaveCmd())
cmd.AddCommand(etcdListCmd())
Expand Down
3 changes: 2 additions & 1 deletion cmd/install/install.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/k0sproject/k0s/pkg/config"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

type installFlags struct {
Expand All @@ -34,7 +35,7 @@ func NewInstallCmd() *cobra.Command {
Use: "install",
Short: "Install k0s on a brand-new system. Must be run as root (or with sudo)",
Args: cobra.NoArgs,
Run: func(*cobra.Command, []string) { /* Enforce arg validation. */ },
RunE: func(*cobra.Command, []string) error { return pflag.ErrHelp }, // Enforce arg validation
}

cmd.AddCommand(installWorkerCmd(&installFlags))
Expand Down
3 changes: 2 additions & 1 deletion cmd/kubeconfig/kubeconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ import (
"github.com/k0sproject/k0s/pkg/config"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

func NewKubeConfigCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "kubeconfig [command]",
Short: "Create a kubeconfig file for a specified user",
Args: cobra.NoArgs,
Run: func(*cobra.Command, []string) { /* Enforce arg validation. */ },
RunE: func(*cobra.Command, []string) error { return pflag.ErrHelp }, // Enforce arg validation
}
cmd.AddCommand(kubeconfigCreateCmd())
cmd.AddCommand(kubeConfigAdminCmd())
Expand Down
3 changes: 2 additions & 1 deletion cmd/token/token.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ import (
"github.com/k0sproject/k0s/pkg/token"

"github.com/spf13/cobra"
"github.com/spf13/pflag"
)

func NewTokenCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "token",
Short: "Manage join tokens",
Args: cobra.NoArgs,
Run: func(*cobra.Command, []string) { /* Enforce arg validation. */ },
RunE: func(*cobra.Command, []string) error { return pflag.ErrHelp }, // Enforce arg validation
}

cmd.AddCommand(tokenListCmd())
Expand Down

0 comments on commit eb5ad6d

Please sign in to comment.