1 2 3 4 5
this can be invoked from the shell with:
The same arguments can be defined with a class:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
1 2 3 4 5
Benefits of argument models:#
- Common arguments can be extracted to models to enforce contracts across commands.
ex. DryRunModel ensures the same short name, long name, description, etc are consistent across all commands using this model.
- FluentValidation framework can be used to validate the model
Argument position cannot be guaranteed to be consistent because the .Net Framework does not guarantee the order properties are reflected.
The GetProperties method does not return properties in a particular order, such as alphabetical or declaration order. Your code must not depend on the order in which properties are returned, because that order varies.
Order can differ on each machine the app is deployed to.
This is not an issue with
Option because options are positional
- Avoid modelling arguments in argument models unless you need to validate them using FluentValidation.
- If you do need to model arguments and you have scripts in place, verify the scripts work as expected on each new machine, after .net framework updates and after new deployments.