fix(cli): check for empty args(cache/get)

This commit is contained in:
lnu 2022-03-21 06:41:04 +01:00 committed by Jan De Dobbeleer
parent 63802ca046
commit 96df24789d
3 changed files with 19 additions and 1 deletions

12
.vscode/launch.json vendored
View file

@ -122,6 +122,16 @@
"request": "attach", "request": "attach",
"port": 9229, "port": 9229,
"preDebugTask": "func: host start" "preDebugTask": "func: host start"
} },
{
"name": "Debug CLI(cache)",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceRoot}/src",
"args": [
"cache",
]
},
] ]
} }

View file

@ -32,6 +32,10 @@ You can do the following:
}, },
Args: cobra.OnlyValidArgs, Args: cobra.OnlyValidArgs,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
_ = cmd.Help()
return
}
env := &environment.ShellEnvironment{ env := &environment.ShellEnvironment{
Version: cliVersion, Version: cliVersion,
} }

View file

@ -27,6 +27,10 @@ This command is used to get the value of the following variables:
}, },
Args: cobra.OnlyValidArgs, Args: cobra.OnlyValidArgs,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
if len(args) == 0 {
_ = cmd.Help()
return
}
env := &environment.ShellEnvironment{ env := &environment.ShellEnvironment{
Version: cliVersion, Version: cliVersion,
} }