1pub mod apig;
2pub mod app;
3pub mod aws;
4pub mod cfn;
5pub mod cloudtrail;
6pub mod common;
7pub mod cw;
8pub mod ec2;
9pub mod ecr;
10pub mod efs;
11pub mod event;
12pub mod fsx;
13pub mod iam;
14pub mod keymap;
15pub mod kms;
16pub mod lambda;
17pub mod s3;
18pub mod session;
19pub mod sqs;
20pub mod table;
21pub mod ui;
22
23pub use app::{
24 App, DetailTab, EventColumn, EventFilterFocus, LogGroupColumn, Service, StreamSort, ViewMode,
25};
26pub use cw::insights::{DateRangeType, InsightsFocus, InsightsState, QueryLanguage, TimeUnit};
27use std::collections::HashMap;
28
29pub fn init() {
31 let mut i18n = HashMap::new();
33 if let Some(home) = std::env::var_os("HOME") {
34 let config_path = std::path::Path::new(&home)
35 .join(".config")
36 .join("rusticity")
37 .join("config.toml");
38
39 if let Ok(contents) = std::fs::read_to_string(&config_path) {
40 if let Ok(toml_map) = contents.parse::<toml::Table>() {
41 if let Some(columns_section) = toml_map.get("columns").and_then(|v| v.as_table()) {
42 flatten_toml(columns_section, "column", &mut i18n);
43 }
44 }
45 }
46 }
47
48 apig::init(&mut i18n);
50 lambda::init(&mut i18n);
51 ec2::init(&mut i18n);
52 ecr::init(&mut i18n);
53 efs::init(&mut i18n);
54 fsx::init(&mut i18n);
55 s3::init(&mut i18n);
56 cw::init(&mut i18n);
57 sqs::init(&mut i18n);
58 cfn::init(&mut i18n);
59 cloudtrail::init(&mut i18n);
60 iam::init(&mut i18n);
61 kms::init(&mut i18n);
62
63 common::set_i18n(i18n);
65}
66
67fn flatten_toml(
68 table: &toml::Table,
69 prefix: &str,
70 map: &mut std::collections::HashMap<String, String>,
71) {
72 for (key, value) in table {
73 let full_key = format!("{}.{}", prefix, key);
74 match value {
75 toml::Value::String(s) => {
76 map.insert(full_key, s.clone());
77 }
78 toml::Value::Table(t) => {
79 flatten_toml(t, &full_key, map);
80 }
81 _ => {}
82 }
83 }
84}
85
86pub use event::EventHandler;
87pub use session::Session;