My personal-knowledge-system, with deeply integrated task tracking and long term goal planning capabilities.

feat/tui: init cli & running tui

authored by suri.codes and committed by tangled.org c476a409 7d57e138

+76 -9
+14 -3
justfile
··· 3 3 default: 4 4 @just --list 5 5 6 + # release mode by default 7 + mode := "debug" 8 + 9 + _cargo_flags := if mode == "release" { "--release" } else { "" } 10 + 11 + # Builds everything in the workspace 6 12 build: 7 - cargo build 13 + cargo build {{_cargo_flags}} 14 + 15 + # Runs Filaments 16 + run: 17 + cargo run {{_cargo_flags}} 8 18 9 - test: 10 - cargo test 19 + # Run all tests 20 + test: 21 + cargo test {{_cargo_flags}}
-1
src/app.rs
··· 35 35 Home, 36 36 } 37 37 38 - #[expect(dead_code)] 39 38 impl App { 40 39 /// Construct a new `App` instance. 41 40 pub fn new(tick_rate: f64, frame_rate: f64) -> Self {
+42
src/cli.rs
··· 1 + use clap::Parser; 2 + 3 + use crate::config::{get_config_dir, get_data_dir}; 4 + 5 + #[derive(Parser, Debug)] 6 + #[command(author, version = version(), about)] 7 + pub struct Cli { 8 + /// Tick rate, i.e. number of ticks per second 9 + #[arg(short, long, value_name = "FLOAT", default_value_t = 4.0)] 10 + pub tick_rate: f64, 11 + 12 + /// Frame rate, i.e. number of frames per second 13 + #[arg(short, long, value_name = "FLOAT", default_value_t = 60.0)] 14 + pub frame_rate: f64, 15 + } 16 + 17 + const VERSION_MESSAGE: &str = concat!( 18 + env!("CARGO_PKG_VERSION"), 19 + "-", 20 + env!("VERGEN_GIT_DESCRIBE"), 21 + " (", 22 + env!("VERGEN_BUILD_DATE"), 23 + ")" 24 + ); 25 + 26 + pub fn version() -> String { 27 + let author = clap::crate_authors!(); 28 + 29 + // let current_exe_path = PathBuf::from(clap::crate_name!()).display().to_string(); 30 + let config_dir_path = get_config_dir().display().to_string(); 31 + let data_dir_path = get_data_dir().display().to_string(); 32 + 33 + format!( 34 + "\ 35 + {VERSION_MESSAGE} 36 + 37 + Authors: {author} 38 + 39 + Config directory: {config_dir_path} 40 + Data directory: {data_dir_path}" 41 + ) 42 + }
+6 -2
src/config.rs
··· 42 42 43 43 impl Config { 44 44 pub fn new() -> Self { 45 - todo!() 45 + Self { 46 + app_dirs: AppDirs { 47 + data_dir: get_data_dir(), 48 + config_dir: get_config_dir(), 49 + }, 50 + } 46 51 } 47 52 } 48 53 ··· 57 62 } 58 63 59 64 /// Returns the path to the OS-agnostic config directory. 60 - #[expect(dead_code)] 61 65 pub fn get_config_dir() -> PathBuf { 62 66 CONFIG_DIRECTORY.clone().unwrap_or_else(|| { 63 67 project_directory().map_or_else(
+2 -2
src/errors.rs
··· 3 3 /// Additionally the panic handler prints different information 4 4 /// based on debug / release builds. 5 5 pub fn init() -> color_eyre::Result<()> { 6 - let (_, eyre_hook) = color_eyre::config::HookBuilder::default() 6 + let (_panic_hook, eyre_hook) = color_eyre::config::HookBuilder::default() 7 7 .panic_section(format!( 8 8 "This is a bug. Please report it at {}", 9 9 env!("CARGO_PKG_REPOSITORY") ··· 25 25 let file_path = handle_dump(&metadata, panic_info); 26 26 print_msg(file_path, &metadata) 27 27 .expect("human-panic: printing error message to console failed"); 28 - eprintln!("{}", panic_hook.panic_report(panic_info)); 28 + eprintln!("{}", _panic_hook.panic_report(panic_info)); 29 29 } 30 30 31 31 // in debug mode do better panic printing
+12 -1
src/main.rs
··· 2 2 //! My (suri.codes) personal-knowledge-system, with deeply integrated task tracking and long term goal planning capabilities. 3 3 //! 4 4 5 + use clap::Parser; 6 + 7 + use crate::{app::App, cli::Cli}; 8 + 5 9 mod app; 10 + mod cli; 6 11 mod components; 7 12 mod config; 8 13 mod errors; ··· 10 15 mod signal; 11 16 mod tui; 12 17 13 - fn main() -> color_eyre::Result<()> { 18 + #[tokio::main] 19 + async fn main() -> color_eyre::Result<()> { 14 20 errors::init()?; 15 21 logging::init()?; 22 + 23 + let args = Cli::parse(); 24 + let mut app = App::new(args.tick_rate, args.frame_rate); 25 + 26 + app.run().await?; 16 27 17 28 Ok(()) 18 29 }