p-ranav / argparse

Argument Parser for Modern C++
MIT License
2.59k stars 244 forks source link

default_value must be called before store_into #347

Open abellgithub opened 4 months ago

abellgithub commented 4 months ago

store_into captures the default value at the time it is called, rather than at parse time. This arrangement ignores the default argument if default_value is called for an argument after store_into. IMO setting a value with the default argument should be deferred into the args are parsed and it is clear that there is no argument provided that would otherwise be associated with the provided default. This doesn't seem to be documented and is easy to get wrong.

I'm happy to take a stab at fixing if this isn't by design.