forked from TheBiochemic/tickets-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.rs
57 lines (45 loc) · 1.32 KB
/
main.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // Uncomment for debugging build
use std::{
sync::{
Arc,
Mutex
},
};
use tickets_rs_adapters::{
LocalTicketAdapter,
GithubTicketAdapter
};
use tickets_rs_core::{
AppConfig,
LocalDatabase,
TicketProvider,
AdapterType
};
use tickets_rs_ui::{
UserInterface,
UIController,
UITheme
};
#[tokio::main]
async fn main() {
let database = {
let database = match LocalDatabase::open("./app_config.db3".to_string()) {
Ok(success) => success,
Err(_) => {
println!("Failed to read Local SQLite Database, exiting!"); return;
}
};
Arc::new(Mutex::new(database))
};
let update_trigger = Arc::new(Mutex::new(false));
let configuration = Arc::new(Mutex::new(AppConfig::new(database)));
let ticket_provider = Arc::new(Mutex::new( {
TicketProvider::new(configuration.clone(), vec![
AdapterType::new::<LocalTicketAdapter>(),
AdapterType::new::<GithubTicketAdapter>(),
], update_trigger.clone())
}));
let ui_controller = UIController::new(configuration.clone(), ticket_provider, update_trigger);
let ui_theme = UITheme::from(configuration);
UserInterface::launch(ui_controller, ui_theme);
}