urfave / cli

A simple, fast, and fun package for building command line apps in Go
https://cli.urfave.org
MIT License
21.91k stars 1.69k forks source link

Feature: Add support for validation functions #1785

Closed dearchap closed 1 year ago

dearchap commented 1 year ago

What type of PR is this?

(REQUIRED)

What this PR does / why we need it:

(REQUIRED)

This PR adds a framework for allowing users to be able to define custom validators on flags. Some very basic rudimentary ones have been provided for demonstration purposes to be able to gather user feedback on easy of use. Other validation functions may be provided in the future if users requests common ones. Note that the validation happens in the same context as when the value is set from the command line so slice flag validations for length may not work as expected.

Which issue(s) this PR fixes:

(REQUIRED)

Special notes for your reviewer:

(fill-in or delete this section)

Testing

(fill-in or delete this section)

Add new validation test cases,

Release Notes

(REQUIRED)

github-actions[bot] commented 1 year ago

What is Frogbot?

dearchap commented 1 year ago

Aww, I liked the validation helper bits! 😭 WDYT about renaming urfave/cli-altsrc to urfave/cli-ext and including them over there?

Hmm thats not a bad idea at all. I'm ok with that. cli-docs would go in there as well ? Would you like to take point on that ?

github-actions[bot] commented 1 year ago


[This comment was generated by JFrog Frogbot 🐸](https://github.com/jfrog/frogbot#readme)
dearchap commented 1 year ago

Aww, I liked the validation helper bits! 😭 WDYT about renaming urfave/cli-altsrc to urfave/cli-ext and including them over there?

Hmm thats not a bad idea at all. I'm ok with that. cli-docs would go in there as well ? Would you like to take point on that ?