diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-06-18 04:40:25 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-06-18 04:40:25 +0800 |
| commit | 7879ac01b24eb9723ec0a814adaee1fc9c52610a (patch) | |
| tree | d1c9a07e3ef8819869494c45e96bcd3e98856bdb /rola-cli/src/lib.rs | |
| parent | 0b8e6e7d18abb94bd99553dc1d2b0ba5d4f265ea (diff) | |
feat(rola-cli): implement bucket creation and CLI entry point
Add bucket creation logic with pre-checks, localized error handling, and
a basic CLI entry point using the mingling framework. Introduce a
placeholder protocol for bucket transfer testing.
Diffstat (limited to 'rola-cli/src/lib.rs')
| -rw-r--r-- | rola-cli/src/lib.rs | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/rola-cli/src/lib.rs b/rola-cli/src/lib.rs index 8b13789..f81c34e 100644 --- a/rola-cli/src/lib.rs +++ b/rola-cli/src/lib.rs @@ -1 +1,43 @@ +use mingling::macros::gen_program; +pub mod res; +pub mod tokio_wrapper; + +mod bucket_mgr; +use bucket_mgr::*; + +mod error; +use error::*; + +gen_program!(); + +pub mod locale { + shakehand::locale!("locales"); + + /// Determines the current locale string used by the application. + /// + /// The locale is resolved by checking environment variables in the following + /// priority order: + /// 1. `JV_LANG` — application-specific variable. + /// 2. `APP_LANG` — general application language override. + /// 3. `LANG` — system locale (e.g. `en_US.UTF-8`). If this variable contains a + /// character encoding suffix (e.g. `.UTF-8`), only the base part is kept, + /// and underscores (`_`) are replaced with hyphens (`-`) to form a + /// language tag (e.g. `en-US`). + /// 4. Falls back to `"en"` if none of the above are set. + pub fn current_locales() -> String { + if let Ok(lang) = std::env::var("JV_LANG") { + return lang; + } + if let Ok(lang) = std::env::var("APP_LANG") { + return lang; + } + if let Ok(lang) = std::env::var("LANG") { + if let Some(base_lang) = lang.split('.').next() { + return base_lang.replace('_', "-"); + } + return lang; + } + "en".to_string() + } +} |
