6a90113e68
The cli package is a leftover from when the "docker" and "dockerd" cli were both maintained in this repository; the only consumer of this is now the dockerd CLI, so we can move this code (it should not be imported by anyone). Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
27 lines
529 B
Go
27 lines
529 B
Go
package main
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// NoArgs validates args and returns an error if there are any args
|
|
func NoArgs(cmd *cobra.Command, args []string) error {
|
|
if len(args) == 0 {
|
|
return nil
|
|
}
|
|
|
|
if cmd.HasSubCommands() {
|
|
return errors.Errorf("\n" + strings.TrimRight(cmd.UsageString(), "\n"))
|
|
}
|
|
|
|
return errors.Errorf(
|
|
"\"%s\" accepts no argument(s).\nSee '%s --help'.\n\nUsage: %s\n\n%s",
|
|
cmd.CommandPath(),
|
|
cmd.CommandPath(),
|
|
cmd.UseLine(),
|
|
cmd.Short,
|
|
)
|
|
}
|