code: func (c *Subcommand) CheckArgs(args []string, minPosCount, maxPosCount int) bool {
  	// Check number of expected positional arguments.
  	if len(args) < minPosCount || (maxPosCount >= 0 && len(args) > maxPosCount) {
  		var err error
  		switch {
  		case maxPosCount == 0:
  			err = NewCLIError("unexpected arguments %v", args)
  		case minPosCount == maxPosCount:
  			err = NewCLIError("expecting %d positional argument, got %d instead", minPosCount, len(args))
  		case maxPosCount >= 0:
  			err = NewCLIError(
  				"expecting from %d to %d positional arguments, got %d instead",
  				minPosCount, maxPosCount, len(args))
  		default:
  			err = NewCLIError(
  				"expecting at least %d positional arguments, got %d instead",
  				minPosCount, len(args))
  		}
  		c.printError(err)
  		return false
  	}
  
  	// Check required unset flags. A flag is considered required if its default
  	// value has form '<...>'.
  	unset := []*flag.Flag{}
  	c.Flags.VisitAll(func(f *flag.Flag) {
  		d := f.DefValue
  		if strings.HasPrefix(d, "<") && strings.HasSuffix(d, ">") && f.Value.String() == d {
  			unset = append(unset, f)
  		}
  	})
  	if len(unset) != 0 {
  		missing := make([]string, len(unset))
  		for i, f := range unset {
  			missing[i] = f.Name
  		}
  		c.printError(NewCLIError("missing required flags: %v", missing))
  		return false
  	}
  
  	return true
  }
docs: // CheckArgs checks command line args.
  //
  // It ensures all required positional and flag-like parameters are set. Setting
  // maxPosCount to -1 indicates there is unbounded number of positional arguments
  // allowed.
  //
  // Returns true if they are, or false (and prints to stderr) if not.