tangled
alpha
login
or
join now
suri.codes
/
filaments
2
fork
atom
My personal-knowledge-system, with deeply integrated task tracking and long term goal planning capabilities.
2
fork
atom
overview
issues
pulls
pipelines
feat/tui: init cli & running tui
suri.codes
2 weeks ago
6104b662
0ba60efe
verified
This commit was signed with the committer's
known signature
.
suri.codes
SSH Key Fingerprint:
SHA256:rTPBPZZoiphDQQwY84AnrZ0gDJZHX9UX/wNGUAU15Sc=
2/2
check.yaml
success
1m 48s
test.yaml
success
1m 23s
+76
-9
6 changed files
expand all
collapse all
unified
split
justfile
src
app.rs
cli.rs
config.rs
errors.rs
main.rs
+14
-3
justfile
···
3
3
default:
4
4
@just --list
5
5
6
6
+
# release mode by default
7
7
+
mode := "debug"
8
8
+
9
9
+
_cargo_flags := if mode == "release" { "--release" } else { "" }
10
10
+
11
11
+
# Builds everything in the workspace
6
12
build:
7
7
-
cargo build
13
13
+
cargo build {{_cargo_flags}}
14
14
+
15
15
+
# Runs Filaments
16
16
+
run:
17
17
+
cargo run {{_cargo_flags}}
8
18
9
9
-
test:
10
10
-
cargo test
19
19
+
# Run all tests
20
20
+
test:
21
21
+
cargo test {{_cargo_flags}}
-1
src/app.rs
···
35
35
Home,
36
36
}
37
37
38
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
1
+
use clap::Parser;
2
2
+
3
3
+
use crate::config::{get_config_dir, get_data_dir};
4
4
+
5
5
+
#[derive(Parser, Debug)]
6
6
+
#[command(author, version = version(), about)]
7
7
+
pub struct Cli {
8
8
+
/// Tick rate, i.e. number of ticks per second
9
9
+
#[arg(short, long, value_name = "FLOAT", default_value_t = 4.0)]
10
10
+
pub tick_rate: f64,
11
11
+
12
12
+
/// Frame rate, i.e. number of frames per second
13
13
+
#[arg(short, long, value_name = "FLOAT", default_value_t = 60.0)]
14
14
+
pub frame_rate: f64,
15
15
+
}
16
16
+
17
17
+
const VERSION_MESSAGE: &str = concat!(
18
18
+
env!("CARGO_PKG_VERSION"),
19
19
+
"-",
20
20
+
env!("VERGEN_GIT_DESCRIBE"),
21
21
+
" (",
22
22
+
env!("VERGEN_BUILD_DATE"),
23
23
+
")"
24
24
+
);
25
25
+
26
26
+
pub fn version() -> String {
27
27
+
let author = clap::crate_authors!();
28
28
+
29
29
+
// let current_exe_path = PathBuf::from(clap::crate_name!()).display().to_string();
30
30
+
let config_dir_path = get_config_dir().display().to_string();
31
31
+
let data_dir_path = get_data_dir().display().to_string();
32
32
+
33
33
+
format!(
34
34
+
"\
35
35
+
{VERSION_MESSAGE}
36
36
+
37
37
+
Authors: {author}
38
38
+
39
39
+
Config directory: {config_dir_path}
40
40
+
Data directory: {data_dir_path}"
41
41
+
)
42
42
+
}
+6
-2
src/config.rs
···
42
42
43
43
impl Config {
44
44
pub fn new() -> Self {
45
45
-
todo!()
45
45
+
Self {
46
46
+
app_dirs: AppDirs {
47
47
+
data_dir: get_data_dir(),
48
48
+
config_dir: get_config_dir(),
49
49
+
},
50
50
+
}
46
51
}
47
52
}
48
53
···
57
62
}
58
63
59
64
/// Returns the path to the OS-agnostic config directory.
60
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
6
-
let (_, eyre_hook) = color_eyre::config::HookBuilder::default()
6
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
28
-
eprintln!("{}", panic_hook.panic_report(panic_info));
28
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
5
+
use clap::Parser;
6
6
+
7
7
+
use crate::{app::App, cli::Cli};
8
8
+
5
9
mod app;
10
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
13
-
fn main() -> color_eyre::Result<()> {
18
18
+
#[tokio::main]
19
19
+
async fn main() -> color_eyre::Result<()> {
14
20
errors::init()?;
15
21
logging::init()?;
22
22
+
23
23
+
let args = Cli::parse();
24
24
+
let mut app = App::new(args.tick_rate, args.frame_rate);
25
25
+
26
26
+
app.run().await?;
16
27
17
28
Ok(())
18
29
}