scuffle-settings
[!WARNING]
This crate is under active development and may not be stable.
A crate designed to provide a simple interface to load and manage settings.
This crate is a wrapper around the config crate and clap crate
to provide a simple interface to load and manage settings.
See the changelog for a full release history.
Feature flags
cli— Enables cli parsing using clapron— Enables the ron formattoml— Enables the toml formatyaml— Enables the yaml formatjson— Enables the json formatjson5— Enables the json5 formastini— Enables the ini formatall-formats— Enables all formatstemplates— Enables templating support via jinjabootstrap— Enables scuffle-bootstrap supportfull— Enables everythingdocs— Enables changelog and documentation of feature flags
Examples
With scuffle_bootstrap
// Define a config struct like this
// You can use all of the serde attributes to customize the deserialization
// Implement scuffle_boostrap::ConfigParser for the config struct like this
bootstrap!;
/// Our global state
;
Without scuffle_bootstrap
// Define a config struct like this
// You can use all of the serde attributes to customize the deserialization
// Parsing options
let options = Options ;
// Parse the settings
let settings: MyConfig = parse_settings?;
See Options for more information on how to customize parsing.
Templates
If the templates feature is enabled, the parser will attempt to render
the configuration file as a jinja template before processing it.
All environment variables set during execution will be available under
the env variable inside the file.
Example TOML file:
= "${{ env.MY_APP_SECRET }}"
Use ${{ and }} for variables, {% and %} for blocks and {# and #} for comments.
Command Line Interface
The following options are available for the CLI:
-
--configor-cPath to a configuration file. This option can be used multiple times to load multiple files.
-
--overrideor-oProvide an override for a configuration value, in the format
KEY=VALUE.
License
This project is licensed under the MIT or Apache-2.0 license. You can choose between one of them if you use this work.
SPDX-License-Identifier: MIT OR Apache-2.0