As seen in #49 there is a general need to support additional ways for users to supply default values to Airline based CLIs. Another common use case from my own $dayjob usage is taking defaults from environment variables. Currently doing this requires providing custom application specific solutions. It would be nice if Airline provided a standard plugin point for this that could then be customised by end users.
My rough idea is to add a new internal phase to the parsing process that would occur after all options and arguments have been passed BUT before we enforce restrictions final validation. The default value supplied would be injected into the list of parsed options/arguments as appropriate ONLY when that particular option/argument hadn't been supplied. Normal restrictions on that option/argument should still apply as usual.
The new DefaultsProvider interface would be pluggable allowing users to configure their desired one on their parser configuration. Likely we'd supply some basic implementations for configuration files (#49) and environment variables.
As seen in #49 there is a general need to support additional ways for users to supply default values to Airline based CLIs. Another common use case from my own $dayjob usage is taking defaults from environment variables. Currently doing this requires providing custom application specific solutions. It would be nice if Airline provided a standard plugin point for this that could then be customised by end users.
My rough idea is to add a new internal phase to the parsing process that would occur after all options and arguments have been passed BUT before we enforce restrictions final validation. The default value supplied would be injected into the list of parsed options/arguments as appropriate ONLY when that particular option/argument hadn't been supplied. Normal restrictions on that option/argument should still apply as usual.
The new
DefaultsProvider
interface would be pluggable allowing users to configure their desired one on their parser configuration. Likely we'd supply some basic implementations for configuration files (#49) and environment variables.