bilal-fazlani / commanddotnet

A modern framework for building modern CLI apps
https://commanddotnet.bilal-fazlani.com
MIT License
569 stars 30 forks source link

Specify min and max arity via attribute #409

Open drewburlingame opened 2 years ago

drewburlingame commented 2 years ago

Currently, the one way to specify a min other than 0 or 1 or a Max other than 0, 1 or "More" is via middleware or interceptor methods. It could be beneficial to be able to assign an arbitrary min and max for collection arguments. This would be done by adding MinCount & MaxCount properties to the Option and Operand attributes and checking the value in the ArgumentArity.Default method. There should be tests to verify the arity is set correctly and an InvalidConfigurationException should be thrown if the values are not valid for the type definition, i.e. if Min or Max is greater than 1 and the type is not an IEnumerable