Implement the 'Partial Options Monoid' pattern for the configuration #130
Labels
CLI
Command Line Interface
config
TOML configuration, config-related CLI options
hacktoberfest
https://hacktoberfest.com/
refactoring
Milestone
This pattern is common in the FP world. The description (in Haskell) can be found here:
The idea is the following:
Create the
Options
type with all configuration fields optionalCreate functions to create this
Options
type from different environments:It's absolutely okay for different environments to fill only some parts of the config.
Implement a function to combine two
Options
with the second argument overriding the previous values if they both are present (otherwise, take the one that is notNone
)Read options on start from all four sources and combine them in the following order of increasing priority (e.g. CLI arguments are more important than everything else)
That's all! With this approach, it should be possible to configure different options from different sources and have a uniform config.
The text was updated successfully, but these errors were encountered: