2018-02-05 16:05:59 -05:00
|
|
|
package cli // import "github.com/docker/docker/cli"
|
2016-04-19 12:59:48 -04:00
|
|
|
|
|
|
|
import (
|
2016-05-26 17:57:31 -04:00
|
|
|
"strings"
|
2016-04-19 12:59:48 -04:00
|
|
|
|
2017-03-09 13:23:45 -05:00
|
|
|
"github.com/pkg/errors"
|
2016-04-19 12:59:48 -04:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
)
|
|
|
|
|
2016-07-03 08:47:39 -04:00
|
|
|
// NoArgs validates args and returns an error if there are any args
|
2016-05-26 17:57:31 -04:00
|
|
|
func NoArgs(cmd *cobra.Command, args []string) error {
|
|
|
|
if len(args) == 0 {
|
2016-04-19 12:59:48 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2016-05-26 17:57:31 -04:00
|
|
|
if cmd.HasSubCommands() {
|
2017-03-09 13:23:45 -05:00
|
|
|
return errors.Errorf("\n" + strings.TrimRight(cmd.UsageString(), "\n"))
|
2016-05-16 17:20:29 -04:00
|
|
|
}
|
|
|
|
|
2017-03-09 13:23:45 -05:00
|
|
|
return errors.Errorf(
|
2016-06-04 10:19:54 -04:00
|
|
|
"\"%s\" accepts no argument(s).\nSee '%s --help'.\n\nUsage: %s\n\n%s",
|
|
|
|
cmd.CommandPath(),
|
2016-05-16 17:20:29 -04:00
|
|
|
cmd.CommandPath(),
|
|
|
|
cmd.UseLine(),
|
|
|
|
cmd.Short,
|
|
|
|
)
|
|
|
|
}
|