Configuration Files
This example demonstrates how to enable loading arguments from a configuration file. The .config() method configures the CLI to load arguments from a configuration file. The method takes a single argument, a ConfigurationProvider. See the docs for ConfigurationProvider here.
For convenience, cli-forge exports some built-in configuration providers. Currently, there are two built-in configuration providers: JsonFile and PackageJson.
Usage of each of these is demonstrated below. Note that when using multiple configuration files, the order in which they are loaded is important. The last configuration file loaded will override any previously loaded configuration files.
When both environment variables and configuration files are used, the order of precedence is as follows:
- CLI Arguments
- Environment Variables
- Configuration Files
- Default Values
This is based on the idea of highest specificity. CLI Arguments are always provided directly by the user. Environment variables can change system-to-system. Configuration files are specific to the project. Default values are equal for all instances of the CLI.