tktax-config
A Rust crate providing configuration logic for the tktax ecosystem. This crate merges file-based and environment-based settings into a centralized data structure, facilitating robust and extensible configuration management. The crate resolves potential conflicts with a predictable order, ensuring determinism in production environments (ἐν διατάξει).
Overview
tktax-config supplies:
- GeneralConfig: Holds global flags, e.g.,
longfor controlling operational modes. - AccountsConfig: Structures bank accounts, savings accounts, and credit accounts via nested
HashMaps. - ProgramConfig: Aggregates sub-configurations and includes specialized logic for Amazon item mapping. Draws from local TOML files (e.g.,
config.toml) and environment variables prefixed withTKTAX.
Usage
-
Add as a Dependency
In your project’s
Cargo.toml:[] = { = "../tktax-config" }(Adjust
pathor version as needed for your setup.) -
Instantiate the Config
-
Environment Variables and File Overrides
- By default,
config.tomlis read from the current directory. - Environment variables such as
TKTAX_GENERAL_LONG=falseoverride file-based values. - Command-line options can be parsed (not shown here) to override defaults for ephemeral debugging.
- By default,
Detailed Structures
ProgramConfig
general: GeneralConfig- Determines overarching behavior.
accounts: Option<AccountsConfig>- Houses checking, savings, and credit accounts.
amazon: Option<AmazonConfig>- Contains Amazon-related data for item mapping.
GeneralConfig
long: bool- Defaults to
true. Indicates whether certain processes run in extended form.
- Defaults to
AccountsConfig
checking: Option<HashMap<u32, String>>- Mapping of checking-account identifiers to descriptions.
savings: Option<HashMap<u32, String>>- Mapping of savings-account identifiers to descriptions.
credit: Option<HashMap<u32, String>>- Mapping of credit-account identifiers to descriptions.
AmazonConfig (From tktax_amazon)
- Provided by the external
tktax-amazoncrate and integrated here.
Example config.toml
[]
= true
[]
= "Main Checking"
= "Secondary Checking"
[]
= "Emergency Fund"
= "Holiday Savings"
[]
= "Primary Credit Card"
= "Travel Rewards Card"
# Example Amazon config would reside under [amazon] depending on tktax_amazon definitions
Amazon-Specific Usage
create_amazon_item_mapmethod inProgramConfigwill yield anAmazonItemMap, derived from data in[amazon]. If no Amazon data is present, it returnsNone.
Contributing
- Fork the repository.
- Create a feature branch.
- Commit your changes with clear messages.
- Open a Pull Request.
License
This project is licensed under the MIT License.
Happy configuring!