From 847367f51ee8d3ada766fc26e8f849ac9758442d Mon Sep 17 00:00:00 2001 From: "Jens K." <47693+sectore@users.noreply.github.com> Date: Thu, 2 Jan 2025 12:16:56 +0100 Subject: [PATCH] Prepare publish (#39) * refactor!: rename `.data` and `.log` files - `timr.data` -> `app.data` - `timr.log` -> `app.log` * refactor!: rename app name `timr` -> `timr-tui` * docs: update README (paths, names, installation) * update Cargo.toml * fix(release): warning: unused variable: `log_dir` --- Cargo.lock | 4 +-- Cargo.toml | 12 +++++++-- README.md | 66 +++++++++++++++++++++++++----------------------- src/constants.rs | 1 - src/logging.rs | 4 +-- src/main.rs | 6 ++--- src/storage.rs | 3 +-- 7 files changed, 51 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 70d526d..0b5d39a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1051,8 +1051,8 @@ dependencies = [ ] [[package]] -name = "timr" -version = "0.1.0" +name = "timr-tui" +version = "0.9.0" dependencies = [ "clap", "color-eyre", diff --git a/Cargo.toml b/Cargo.toml index 8048e6c..5ac1402 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,15 @@ [package] -name = "timr" -version = "0.1.0" +name = "timr-tui" +version = "0.9.0" +description = "TUI to organize your time: Pomodoro, Countdown, Timer." edition = "2021" +rust-version = "1.82.0" +homepage = "https://github.com/sectore/timr-tui" +repository = "https://github.com/sectore/timr-tui" +readme = "README.md" +license = "MIT" +keywords = ["tui", "timer", "countdown", "pomodoro"] +categories = ["command-line-utilities"] [dependencies] ratatui = "0.29.0" diff --git a/README.md b/README.md index e253fd7..90930d7 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,6 @@ -# tim:r +# timr-tui -**Pronounced `/ˈtʌɪmə/` or `/ˈtaɪmər/`.** - -`tim:r` is a TUI app to help organize one of the most important thing you might have in live: `time`! +TUI to organize your time: Pomodoro, Countdown, Timer. - `[t]imer` Check the time on anything you are you doing. - `[c]ountdown` Use it for your workout, yoga session, meditation, handstand or whatever. @@ -50,10 +48,12 @@ _Side note:_ Theme colors depend on your terminal preferences. menu -# Args ⚙️ +# CLI ```sh -Usage: timr [OPTIONS] +timr-tui --help + +Usage: timr-tui [OPTIONS] Options: -c, --countdown Countdown time to start from. Formats: 'ss', 'mm:ss', or 'hh:mm:ss' [default: 10:00] @@ -68,6 +68,20 @@ Options: -V, --version Print version ``` +# Installation + +From [crates.io](https://crates.io/crates/timr-tui) run: + +```sh +cargo install timr-tui +``` + +Latest version from git repository: + +```sh +cargo install --git https://github.com/sectore/timr-tui +``` + # Build from source 🔧 ## Requirements @@ -121,38 +135,26 @@ nix build .#windows ## Persistant app state -Stored on file system. +Stored on file system: -- `Linux` ```sh -cat ~/.local/state/timr/data/timr.data -``` - -- `macOS` -```sh -cat /Users/{user}/Library/Application Support/timr/data/timr.data -``` - -- `Windows` -```sh -cat C:/Users/{user}/AppData/Local/timr/data/timr.data +# Linux +~/.local/state/timr-tui/data/app.data +# macOS +/Users/{user}/Library/Application Support/timr-tui/data/app.data +# Windows +C:/Users/{user}/AppData/Local/timr-tui/data/app.data ``` ## Logs -In `debug` mode only. +In `debug` mode only. Locations: -- `Linux` ```sh -tail -f ~/.local/state/timr/logs/timr.log -``` - -- `macOS` -```sh -tail -f /Users/{user}/Library/Application Support/timr/logs/timr.log -``` - -- `Windows` -```sh -tail -f C:/Users/{user}/AppData/Local/timr/logs/timr.log +# Linux +~/.local/state/timr/logs/app.log +# macOS +/Users/{user}/Library/Application Support/timr-tui/logs/app.log +# `Windows` +C:/Users/{user}/AppData/Local/timr-tui/logs/app.log ``` diff --git a/src/constants.rs b/src/constants.rs index e42ce47..da9dd3e 100644 --- a/src/constants.rs +++ b/src/constants.rs @@ -1,5 +1,4 @@ pub static APP_NAME: &str = env!("CARGO_PKG_NAME"); -// TODO: Grab those values from `Args` pub static TICK_VALUE_MS: u64 = 1000 / 10; // 0.1 sec in milliseconds pub static FPS_VALUE_MS: u64 = 1000 / 60; // 60 FPS in milliseconds diff --git a/src/logging.rs b/src/logging.rs index 861e229..80fb68b 100644 --- a/src/logging.rs +++ b/src/logging.rs @@ -6,8 +6,6 @@ use tracing_subscriber::{ self, prelude::__tracing_subscriber_SubscriberExt, util::SubscriberInitExt, }; -use crate::constants::APP_NAME; - pub struct Logger { log_dir: PathBuf, } @@ -18,7 +16,7 @@ impl Logger { } pub fn init(&self) -> Result<()> { - let log_path = self.log_dir.join(format!("{}.log", APP_NAME)); + let log_path = self.log_dir.join("app.log"); let log_file = fs::File::create(log_path)?; let fmt_layer = tracing_subscriber::fmt::layer() .with_file(true) diff --git a/src/main.rs b/src/main.rs index 8549879..dc04cc3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -22,9 +22,9 @@ use storage::{AppStorage, Storage}; #[tokio::main] async fn main() -> Result<()> { - let Config { log_dir, data_dir } = Config::init()?; + let cfg = Config::init()?; #[cfg(debug_assertions)] - logging::Logger::new(log_dir).init()?; + logging::Logger::new(cfg.log_dir).init()?; color_eyre::install()?; // get args given by CLI @@ -34,7 +34,7 @@ async fn main() -> Result<()> { let events = events::Events::new(); // check persistant storage - let storage = Storage::new(data_dir); + let storage = Storage::new(cfg.data_dir); // option to reset previous stored data to `default` let stg = if args.reset { AppStorage::default() diff --git a/src/storage.rs b/src/storage.rs index e965319..a30383f 100644 --- a/src/storage.rs +++ b/src/storage.rs @@ -1,6 +1,5 @@ use crate::{ common::{Content, Style}, - constants::APP_NAME, widgets::pomodoro::Mode as PomodoroMode, }; use color_eyre::eyre::Result; @@ -65,7 +64,7 @@ impl Storage { } fn get_storage_path(&self) -> PathBuf { - self.data_dir.join(format!("{}.data", APP_NAME)) + self.data_dir.join("app.data") } pub fn save(&self, data: AppStorage) -> Result<()> {