Skip to content

Commit 5085352

Browse files
authored
Make error if arguments are given for subcommands that require no arguments. (#205)
1 parent 61ab8c7 commit 5085352

File tree

8 files changed

+11
-0
lines changed

8 files changed

+11
-0
lines changed

cmd/delete.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Use with caution. This deletes everything and a startup afterwards is like the
2121
initial startup of Colima.
2222
2323
If you simply want to reset the Kubernetes cluster, run 'colima kubernetes reset'.`,
24+
Args: cobra.NoArgs,
2425
RunE: func(cmd *cobra.Command, args []string) error {
2526
if !deleteCmdArgs.force {
2627
y := cli.Prompt("are you sure you want to delete " + config.Profile().DisplayName + " and all settings")

cmd/kubernetes.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ var kubernetesStartCmd = &cobra.Command{
3434
Use: "start",
3535
Short: "start the Kubernetes cluster",
3636
Long: `Start the Kubernetes cluster.`,
37+
Args: cobra.NoArgs,
3738
RunE: func(cmd *cobra.Command, args []string) error {
3839
app := newApp()
3940
k, err := app.Kubernetes()
@@ -54,6 +55,7 @@ var kubernetesStopCmd = &cobra.Command{
5455
Use: "stop",
5556
Short: "stop the Kubernetes cluster",
5657
Long: `Stop the Kubernetes cluster.`,
58+
Args: cobra.NoArgs,
5759
RunE: func(cmd *cobra.Command, args []string) error {
5860
app := newApp()
5961
k, err := app.Kubernetes()
@@ -73,6 +75,7 @@ var kubernetesDeleteCmd = &cobra.Command{
7375
Use: "delete",
7476
Short: "delete the Kubernetes cluster",
7577
Long: `Delete the Kubernetes cluster.`,
78+
Args: cobra.NoArgs,
7679
RunE: func(cmd *cobra.Command, args []string) error {
7780
app := newApp()
7881
k, err := app.Kubernetes()
@@ -97,6 +100,7 @@ This resets the Kubernetes cluster and all Kubernetes objects
97100
will be deleted.
98101
99102
The Kubernetes images are cached making the startup (after reset) much faster.`,
103+
Args: cobra.NoArgs,
100104
RunE: func(cmd *cobra.Command, args []string) error {
101105
app := newApp()
102106
k, err := app.Kubernetes()

cmd/list.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ var listCmd = &cobra.Command{
1919
Long: `List all created instances.
2020
2121
A new instance can be created during 'colima start' by specifying the '--profile' flag.`,
22+
Args: cobra.NoArgs,
2223
RunE: func(cmd *cobra.Command, args []string) error {
2324
instances, err := lima.Instances()
2425
if err != nil {

cmd/nerdctl.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ var nerdctlLinkFunc = func() *cobra.Command {
5454
Use: "install",
5555
Short: "install nerdctl alias script on the host",
5656
Long: `Install nerdctl alias script on the host. The script will be installed at ` + nerdctlDefaultInstallPath + `.`,
57+
Args: cobra.NoArgs,
5758
PreRun: func(cmd *cobra.Command, args []string) {
5859
// check if /usr/local/bin is writeable and no need for sudo
5960

cmd/start.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ The --runtime, --disk and --arch flags are only used on initial start and ignore
2828
" colima start --cpu 4 --memory 8 --disk 100\n" +
2929
" colima start --arch aarch64\n" +
3030
" colima start --dns 1.1.1.1 --dns 8.8.8.8",
31+
Args: cobra.NoArgs,
3132
RunE: func(cmd *cobra.Command, args []string) error {
3233
return newApp().Start(startCmdArgs.Config)
3334
},

cmd/status.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var statusCmd = &cobra.Command{
1010
Use: "status",
1111
Short: "show the status of Colima",
1212
Long: `Show the status of Colima`,
13+
Args: cobra.NoArgs,
1314
RunE: func(cmd *cobra.Command, args []string) error {
1415
return newApp().Status()
1516
},

cmd/stop.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var stopCmd = &cobra.Command{
1313
1414
The state of the VM is persisted at stop. A start afterwards
1515
should return it back to its previous state.`,
16+
Args: cobra.NoArgs,
1617
RunE: func(cmd *cobra.Command, args []string) error {
1718
return newApp().Stop()
1819
},

cmd/version.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ var versionCmd = &cobra.Command{
1414
Use: "version",
1515
Short: "print the version of Colima",
1616
Long: `Print the version of Colima`,
17+
Args: cobra.NoArgs,
1718
Run: func(cmd *cobra.Command, args []string) {
1819
version := config.AppVersion()
1920
fmt.Println(config.AppName, "version", version.Version)

0 commit comments

Comments
 (0)