▲ | Lvl999Noob 3 days ago | |
The difference, in my opinion, is that you received the cli args in the form ``` some_cli <some args> --some-option --no-some-option ``` Before parsing, the argument array contains both the flags to enable and disable the option. Validation would either throw an error or accept it as either enabled or disabled. But importantly, it wouldn't change the arguments. If the assumption is that the last option overwrites anything before it then the cli command is valid with the option disabled. And now, correct behaviour relies on all the code using that option to always make the same assumption. Parsing, on the other hand, would put create a new config where `option` is an enum - either enabled or disabled or not given. No confusion about multiple flags or anything. It provides a single view for the rest of the program of what the input config was. Whether that parsing is done by a third party library or first party code, declaratively or imperatively, is besides the point. |