| Crates.io | tktax-config |
| lib.rs | tktax-config |
| version | 0.2.2 |
| created_at | 2025-02-01 02:47:34.189589+00 |
| updated_at | 2025-02-01 02:47:34.189589+00 |
| description | Configuration handling for tktax, integrating environment- and file-based settings. |
| homepage | https://github.com/your_org/tktax-config |
| repository | https://github.com/klebs6/tktax |
| max_upload_size | |
| id | 1538030 |
| size | 84,649 |
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 (ἐν διατάξει).
tktax-config supplies:
long for controlling operational modes.HashMaps.config.toml) and environment variables prefixed with TKTAX.Add as a Dependency
In your project’s Cargo.toml:
[dependencies]
tktax-config = { path = "../tktax-config" }
(Adjust path or version as needed for your setup.)
Instantiate the Config
fn main() {
// Leverage the `Default` trait to parse from `config.toml`
// and environment variables (`TKTAX_*`).
let config = tktax_config::ProgramConfig::default();
// Example usage
if config.general().long() {
println!("Long-mode enabled!");
}
if let Some(accounts) = config.accounts() {
// Access checking, savings, credit, etc.
}
}
Environment Variables and File Overrides
config.toml is read from the current directory.TKTAX_GENERAL_LONG=false override file-based values.ProgramConfiggeneral: GeneralConfig
accounts: Option<AccountsConfig>
amazon: Option<AmazonConfig>
GeneralConfiglong: bool
true. Indicates whether certain processes run in extended form.AccountsConfigchecking: Option<HashMap<u32, String>>
savings: Option<HashMap<u32, String>>
credit: Option<HashMap<u32, String>>
AmazonConfig (From tktax_amazon)tktax-amazon crate and integrated here.config.toml[general]
long = true
[accounts.checking]
101 = "Main Checking"
202 = "Secondary Checking"
[accounts.savings]
303 = "Emergency Fund"
404 = "Holiday Savings"
[accounts.credit]
505 = "Primary Credit Card"
606 = "Travel Rewards Card"
# Example Amazon config would reside under [amazon] depending on tktax_amazon definitions
create_amazon_item_map method in ProgramConfig will yield an AmazonItemMap, derived from data in [amazon]. If no Amazon data is present, it returns None.This project is licensed under the MIT License.
Happy configuring!