From 9934507d74c97bccb753b04873eb74652600b6ff Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Tue, 26 Feb 2019 12:28:35 -0700 Subject: Command-line input validation: reject unused args Several podman commands accept no subcommands. Some of those were not actually checking, though, which could lead to user confusion. Added validation where missing; and, refactored to minimize duplication. (Side note: I decided against using cobra.NoArgs because its error message, "unknown command", misleadingly implies that there are known ones). Also added validation to varlink Signed-off-by: Ed Santiago --- cmd/podman/volume_ls.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'cmd/podman/volume_ls.go') diff --git a/cmd/podman/volume_ls.go b/cmd/podman/volume_ls.go index 5adfc1e91..6855f38e0 100644 --- a/cmd/podman/volume_ls.go +++ b/cmd/podman/volume_ls.go @@ -49,6 +49,7 @@ and the output format can be changed to JSON or a user specified Go template. _volumeLsCommand = &cobra.Command{ Use: "ls", Aliases: []string{"list"}, + Args: noSubArgs, Short: "List volumes", Long: volumeLsDescription, RunE: func(cmd *cobra.Command, args []string) error { @@ -76,10 +77,6 @@ func volumeLsCmd(c *cliconfig.VolumeLsValues) error { } defer runtime.Shutdown(false) - if len(c.InputArgs) > 0 { - return errors.Errorf("too many arguments, ls takes no arguments") - } - opts := volumeLsOptions{ Quiet: c.Quiet, } -- cgit v1.2.3-54-g00ecf