Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Generalize ValidArgs: use it implicitly with any validator
5 of the commits in this PR are about refactoring args_test.go. The sixth one (feat: generalize ValidArgs; use it implicitly with any validator) moves the validation of ValidArgs from args.go to command.go. As a result: - Any validator can be used along with ValidArgs. ValidArgs is checked first, and then the defined validator. - OnlyValidArgs and ExactValidArgs are deprecated. args_test.go is updated accordingly: ``` === RUN TestNoArgs --- PASS: TestNoArgs (0.00s) === RUN TestNoArgsWithArgs --- PASS: TestNoArgsWithArgs (0.00s) === RUN TestNoArgsWithArgsWithValid --- PASS: TestNoArgsWithArgsWithValid (0.00s) === RUN TestArbitraryArgs --- PASS: TestArbitraryArgs (0.00s) === RUN TestArbitraryArgsWithValid --- PASS: TestArbitraryArgsWithValid (0.00s) === RUN TestArbitraryArgsWithValidWithInvalidArgs --- PASS: TestArbitraryArgsWithValidWithInvalidArgs (0.00s) === RUN TestMinimumNArgs --- PASS: TestMinimumNArgs (0.00s) === RUN TestMinimumNArgsWithValid --- PASS: TestMinimumNArgsWithValid (0.00s) === RUN TestMinimumNArgsWithValidWithInvalidArgs --- PASS: TestMinimumNArgsWithValidWithInvalidArgs (0.00s) === RUN TestMinimumNArgsWithLessArgs --- PASS: TestMinimumNArgsWithLessArgs (0.00s) === RUN TestMinimumNArgsWithLessArgsWithValid --- PASS: TestMinimumNArgsWithLessArgsWithValid (0.00s) === RUN TestMinimumNArgsWithLessArgsWithValidWithInvalidArgs --- PASS: TestMinimumNArgsWithLessArgsWithValidWithInvalidArgs (0.00s) === RUN TestMaximumNArgs --- PASS: TestMaximumNArgs (0.00s) === RUN TestMaximumNArgsWithValid --- PASS: TestMaximumNArgsWithValid (0.00s) === RUN TestMaximumNArgsWithValidWithInvalidArgs --- PASS: TestMaximumNArgsWithValidWithInvalidArgs (0.00s) === RUN TestMaximumNArgsWithMoreArgs --- PASS: TestMaximumNArgsWithMoreArgs (0.00s) === RUN TestMaximumNArgsWithMoreArgsWithValid --- PASS: TestMaximumNArgsWithMoreArgsWithValid (0.00s) === RUN TestMaximumNArgsWithMoreArgsWithValidWithInvalidArgs --- PASS: TestMaximumNArgsWithMoreArgsWithValidWithInvalidArgs (0.00s) === RUN TestExactArgs --- PASS: TestExactArgs (0.00s) === RUN TestExactArgsWithValid --- PASS: TestExactArgsWithValid (0.00s) === RUN TestExactArgsWithValidWithInvalidArgs --- PASS: TestExactArgsWithValidWithInvalidArgs (0.00s) === RUN TestExactArgsWithInvalidCount --- PASS: TestExactArgsWithInvalidCount (0.00s) === RUN TestExactArgsWithInvalidCountWithValid --- PASS: TestExactArgsWithInvalidCountWithValid (0.00s) === RUN TestExactArgsWithInvalidCountWithValidWithInvalidArgs --- PASS: TestExactArgsWithInvalidCountWithValidWithInvalidArgs (0.00s) === RUN TestRangeArgs --- PASS: TestRangeArgs (0.00s) === RUN TestRangeArgsWithValid --- PASS: TestRangeArgsWithValid (0.00s) === RUN TestRangeArgsWithValidWithInvalidArgs --- PASS: TestRangeArgsWithValidWithInvalidArgs (0.00s) === RUN TestRangeArgsWithInvalidCount --- PASS: TestRangeArgsWithInvalidCount (0.00s) === RUN TestRangeArgsWithInvalidCountWithValid --- PASS: TestRangeArgsWithInvalidCountWithValid (0.00s) === RUN TestRangeArgsWithInvalidCountWithValidWithInvalidArgs --- PASS: TestRangeArgsWithInvalidCountWithValidWithInvalidArgs (0.00s) === RUN TestRootTakesNoArgs --- PASS: TestRootTakesNoArgs (0.00s) === RUN TestRootTakesArgs --- PASS: TestRootTakesArgs (0.00s) === RUN TestChildTakesNoArgs --- PASS: TestChildTakesNoArgs (0.00s) === RUN TestChildTakesArgs --- PASS: TestChildTakesArgs (0.00s) ``` Merge spf13/cobra#841 Fix #838 and Fix #745
- Loading branch information