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