main: lazy_static prototyping, env handling
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -5,11 +5,12 @@
|
|||||||
* SPDX-License-Identifier: (0BSD or MIT)
|
* SPDX-License-Identifier: (0BSD or MIT)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//#[macro_use]
|
|
||||||
//extern crate lazy_static;
|
|
||||||
// suppress creation of a new console window on window
|
// suppress creation of a new console window on window
|
||||||
#![windows_subsystem = "windows"]
|
#![windows_subsystem = "windows"]
|
||||||
|
|
||||||
|
//#[macro_use]
|
||||||
|
//extern crate lazy_static;
|
||||||
|
|
||||||
//use chrono::{Local, DateTime};
|
//use chrono::{Local, DateTime};
|
||||||
use locales::t;
|
use locales::t;
|
||||||
//use serde::{Deserialize, Serialize};
|
//use serde::{Deserialize, Serialize};
|
||||||
@@ -35,12 +36,30 @@ mod parse_args;
|
|||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct Environment {
|
struct Environment {
|
||||||
test_lang: String,
|
test_lang: String,
|
||||||
log: String,
|
rust_log: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
//#[cfg(feature = "light-theme")]
|
//#[cfg(feature = "light-theme")]
|
||||||
static STYLESHEET: &'static str = include_str!("../resources/stylesheets/advotracker.css");
|
static STYLESHEET: &'static str = include_str!("../resources/stylesheets/advotracker.css");
|
||||||
|
|
||||||
|
// lazy_static! {
|
||||||
|
// static ref LANG: String + 'static = {
|
||||||
|
// let mut lang = env::var("LANG").unwrap_or("en".to_string())
|
||||||
|
// };
|
||||||
|
// static ref TEST_LANG: String + 'static = {
|
||||||
|
// let mut test_lang = {
|
||||||
|
// // testing environment: read from .env file
|
||||||
|
// dotenv().ok();
|
||||||
|
// match envy::from_env::<Environment>() {
|
||||||
|
// Ok(environment) => {
|
||||||
|
// if environment.test_lang != lang { lang = environment.test_lang; }
|
||||||
|
// },
|
||||||
|
// Err(e) => { debug!(target: "advotracker", "{}", e); }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// };
|
||||||
|
// }
|
||||||
|
|
||||||
fn get_theme() -> ThemeValue {
|
fn get_theme() -> ThemeValue {
|
||||||
ThemeValue::create_from_css(DEFAULT_THEME_CSS)
|
ThemeValue::create_from_css(DEFAULT_THEME_CSS)
|
||||||
//ThemeValue::create_from_css(LIGHT_THEME_EXTENSION_CSS)
|
//ThemeValue::create_from_css(LIGHT_THEME_EXTENSION_CSS)
|
||||||
@@ -73,7 +92,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
|
|
||||||
// respect dotenv environment (e.g for testing)
|
// respect dotenv environment (e.g for testing)
|
||||||
// -> overwrites the preset default values
|
// -> overwrites the preset default values
|
||||||
let log = dotenv::var("RUST_LOG").unwrap_or_else(|_| String::from("None"));
|
let rust_log = dotenv::var("RUST_LOG").unwrap_or_else(|_| String::from("None"));
|
||||||
|
|
||||||
// initialize the tracing subsystem
|
// initialize the tracing subsystem
|
||||||
// a drop in replacement for classical logging
|
// a drop in replacement for classical logging
|
||||||
@@ -82,7 +101,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
let span = tracing::span!(Level::TRACE, "advotracker");
|
let span = tracing::span!(Level::TRACE, "advotracker");
|
||||||
let _enter = span.enter();
|
let _enter = span.enter();
|
||||||
let subscriber = fmt::Subscriber::builder()
|
let subscriber = fmt::Subscriber::builder()
|
||||||
.with_env_filter(&log)
|
.with_env_filter(&rust_log)
|
||||||
//.with_max_level(tracing::Level::DEBUG)
|
//.with_max_level(tracing::Level::DEBUG)
|
||||||
.finish();
|
.finish();
|
||||||
|
|
||||||
@@ -113,10 +132,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// initialize viperus structure
|
// initialize viperus structure
|
||||||
let mut viperus = Viperus::new();
|
let mut viperus = Viperus::new();
|
||||||
|
|
||||||
// lazy_static! {
|
|
||||||
// static ref VIPERUS: Viperus + 'static = { let mut viperus = Viperus::new(); };
|
|
||||||
// static ref VIPERUS_COUNT: usize = VIPERUS.len();
|
|
||||||
// }
|
|
||||||
// lazy_static! {
|
// lazy_static! {
|
||||||
// static ref HASHMAP: HashMap<usize, PolicyCode> = {
|
// static ref HASHMAP: HashMap<usize, PolicyCode> = {
|
||||||
// let mut policy_numbers = HashMap::new();
|
// let mut policy_numbers = HashMap::new();
|
||||||
@@ -180,8 +195,6 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// },
|
// },
|
||||||
//}
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Application::from_name("nwx.advotracker")
|
Application::from_name("nwx.advotracker")
|
||||||
.window(move |ctx| {
|
.window(move |ctx| {
|
||||||
Window::new()
|
Window::new()
|
||||||
|
|||||||
Reference in New Issue
Block a user