3.4.1 Value Sources

The command-line is not the only place where Clon looks for option values. Other sources for option values are: fallback values, environment variables and default values. The existence of a fallback value, environment variable or default value should be advertised in the application’s help string (see Output).

When Clon attempts to retrieve a value for a particular option, it always does so in a specific order: first, the command-line is searched. If an argument is present, it is used. Otherwise, a fallback or default value is used in that order (note that when an option’s argument is optional, the option is required to provide at least a fallback or a default value). Next, an environment variable is tried (when appropriate). Finally, when everything else fails, the option’s default value is used (if any).

Clon always scans the command-line from left to right, and stops at the first match. Please note that the match in question may be a regular option call or a pack, depending on what appears first on the command-line. There is no concept of priority amongst option forms.

Also, note that it is possible to provide several calls to the same option on a single command-line. Some applications may take advantage of this: every consecutive request for an option will use the next match on the command-line until there is none left.

Finally, note that fallback or default values don’t make any sense for flags, but flags can still be associated with environment variables. In such a case, the very existence of the variable in the environment, regardless of its value, stands for the presence of the corresponding option on the command-line.