Add dots in comments of args.go
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Albert Nigmatzianov · committed by Albert Nigmatzianov · parent 18eefcd · Browse files · 1 file·+8 added−17 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+8 added−17 removed
- other:+8 added−17 removed
Provenance
- Commit
099c5ae- Tree
84ad84f- Author
Albert Nigmatzianov <albertnigma@gmail.com>- Committer
Albert Nigmatzianov <albertnigma@gmail.com>- Parent
18eefcd
1 file changed+8 added−17 removed
modified:args.go+8 added-17 removed
14 unmodified lines15 if !cmd.HasSubCommands() {16 return nil17 }18 19- // root command with subcommands, do subcommand checking19+ // root command with subcommands, do subcommand checking.20 if !cmd.HasParent() && len(args) > 0 {21 return fmt.Errorf("unknown command %q for %q%s", args[0], cmd.CommandPath(), cmd.findSuggestions(args[0]))22 }23 return nil24 }25 26-// NoArgs returns an error if any args are included26+// NoArgs returns an error if any args are included.27 func NoArgs(cmd *Command, args []string) error {28 if len(args) > 0 {29 return fmt.Errorf("unknown command %q for %q", args[0], cmd.CommandPath())30 }31 return nil32 }33 34-// OnlyValidArgs returns an error if any args are not in the list of ValidArgs34+// OnlyValidArgs returns an error if any args are not in the list of ValidArgs.35 func OnlyValidArgs(cmd *Command, args []string) error {36 if len(cmd.ValidArgs) > 0 {37 for _, v := range args {38 if !stringInSlice(v, cmd.ValidArgs) {3 unmodified lines42 }43 return nil44 }45 46-func stringInSlice(a string, list []string) bool {47- for _, b := range list {48- if b == a {49- return true50- }51- }52- return false53-}54-55-// ArbitraryArgs never returns an error46+// ArbitraryArgs never returns an error.47 func ArbitraryArgs(cmd *Command, args []string) error {48 return nil49 }50 60-// MinimumNArgs returns an error if there is not at least N args51+// MinimumNArgs returns an error if there is not at least N args.52 func MinimumNArgs(n int) PositionalArgs {53 return func(cmd *Command, args []string) error {54 if len(args) < n {55 return fmt.Errorf("requires at least %d arg(s), only received %d", n, len(args))1 unmodified line57 return nil58 }59 }60 70-// MaximumNArgs returns an error if there are more than N args61+// MaximumNArgs returns an error if there are more than N args.62 func MaximumNArgs(n int) PositionalArgs {63 return func(cmd *Command, args []string) error {64 if len(args) > n {65 return fmt.Errorf("accepts at most %d arg(s), received %d", n, len(args))1 unmodified line67 return nil68 }69 }70 80-// ExactArgs returns an error if there are not exactly n args71+// ExactArgs returns an error if there are not exactly n args.72 func ExactArgs(n int) PositionalArgs {73 return func(cmd *Command, args []string) error {74 if len(args) != n {75 return fmt.Errorf("accepts %d arg(s), received %d", n, len(args))1 unmodified line77 return nil78 }79 }80 90-// RangeArgs returns an error if the number of args is not within the expected range81+// RangeArgs returns an error if the number of args is not within the expected range.82 func RangeArgs(min int, max int) PositionalArgs {83 return func(cmd *Command, args []string) error {84 if len(args) < min || len(args) > max {85 return fmt.Errorf("accepts between %d and %d arg(s), received %d", min, max, len(args))4 unmodified lines