diff options
| author | Kevin Hoerr <kjhoerr@submelon.dev> | 2026-02-25 22:28:26 +0000 |
|---|---|---|
| committer | Kevin Hoerr <kjhoerr@submelon.dev> | 2026-02-25 22:28:26 +0000 |
| commit | 8a4f311c1d1fa4d978c93e58d95bf59a8a38b587 (patch) | |
| tree | 2d0b2c526d4bc25ba048664e77519cf278702a37 /src/main/rust/main.rs | |
| parent | d96b45f468a1587fd0ba1e8ecd0552478d7e6f90 (diff) | |
| download | equity-tracker-8a4f311c1d1fa4d978c93e58d95bf59a8a38b587.tar.gz equity-tracker-8a4f311c1d1fa4d978c93e58d95bf59a8a38b587.tar.bz2 equity-tracker-8a4f311c1d1fa4d978c93e58d95bf59a8a38b587.zip | |
Add context and initialization
Diffstat (limited to 'src/main/rust/main.rs')
| -rw-r--r-- | src/main/rust/main.rs | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/main/rust/main.rs b/src/main/rust/main.rs index e231aae..0805796 100644 --- a/src/main/rust/main.rs +++ b/src/main/rust/main.rs @@ -1,3 +1,5 @@ +pub mod store; + use crossterm::event::{self, Event, KeyCode, KeyEvent, KeyEventKind}; use miette::{Diagnostic, IntoDiagnostic, Result}; use ratatui::{ @@ -9,10 +11,12 @@ use ratatui::{ text::{Line, Text}, widgets::{Block, Paragraph, Widget}, }; +use store::{Context, Store}; use thiserror::Error; -#[derive(Debug, Default)] +#[derive(Default)] pub struct App { + context: Context, counter: u8, exit: bool, } @@ -27,10 +31,20 @@ pub struct OverflowError { #[cfg(not(tarpaulin_include))] fn main() -> Result<()> { - ratatui::run(|term| App::default().run(term)) + ratatui::run(|term| App::default().init_context()?.run(term)) } impl App { + // Initializes context + pub fn init_context(&mut self) -> Result<&mut Self> { + match &mut self.context { + Context::SQLite(s) => { + s.init()?; + } + } + Ok(self) + } + /// runs the application's main loop until the user quits #[cfg(not(tarpaulin_include))] pub fn run(&mut self, terminal: &mut DefaultTerminal) -> Result<()> { |
