github.com/wozhu6104/docker@v20.10.10+incompatible/cli/required.go (about) 1 package cli // import "github.com/docker/docker/cli" 2 3 import ( 4 "strings" 5 6 "github.com/pkg/errors" 7 "github.com/spf13/cobra" 8 ) 9 10 // NoArgs validates args and returns an error if there are any args 11 func NoArgs(cmd *cobra.Command, args []string) error { 12 if len(args) == 0 { 13 return nil 14 } 15 16 if cmd.HasSubCommands() { 17 return errors.Errorf("\n" + strings.TrimRight(cmd.UsageString(), "\n")) 18 } 19 20 return errors.Errorf( 21 "\"%s\" accepts no argument(s).\nSee '%s --help'.\n\nUsage: %s\n\n%s", 22 cmd.CommandPath(), 23 cmd.CommandPath(), 24 cmd.UseLine(), 25 cmd.Short, 26 ) 27 }