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/refresh.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'cmd/podman/refresh.go') diff --git a/cmd/podman/refresh.go b/cmd/podman/refresh.go index 641748452..2eb3d25a8 100644 --- a/cmd/podman/refresh.go +++ b/cmd/podman/refresh.go @@ -15,6 +15,7 @@ var ( refreshDescription = "The refresh command resets the state of all containers to handle database changes after a Podman upgrade. All running containers will be restarted." _refreshCommand = &cobra.Command{ Use: "refresh", + Args: noSubArgs, Short: "Refresh container state", Long: refreshDescription, RunE: func(cmd *cobra.Command, args []string) error { @@ -31,10 +32,6 @@ func init() { } func refreshCmd(c *cliconfig.RefreshValues) error { - if len(c.InputArgs) > 0 { - return errors.Errorf("refresh does not accept any arguments") - } - runtime, err := libpodruntime.GetRuntime(&c.PodmanCommand) if err != nil { return errors.Wrapf(err, "error creating libpod runtime") -- cgit v1.2.3-54-g00ecf