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/pod_create.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'cmd/podman/pod_create.go') diff --git a/cmd/podman/pod_create.go b/cmd/podman/pod_create.go index f1bbecb84..43c211b2c 100644 --- a/cmd/podman/pod_create.go +++ b/cmd/podman/pod_create.go @@ -24,6 +24,7 @@ var ( _podCreateCommand = &cobra.Command{ Use: "create", + Args: noSubArgs, Short: "Create a new empty pod", Long: podCreateDescription, RunE: func(cmd *cobra.Command, args []string) error { @@ -59,9 +60,6 @@ func podCreateCmd(c *cliconfig.PodCreateValues) error { podIdFile *os.File ) - if len(c.InputArgs) > 0 { - return errors.New("podman pod create does not accept any arguments") - } runtime, err := adapter.GetRuntime(&c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") -- cgit v1.2.3-54-g00ecf