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`
This commit is contained in:
Jens K. 2025-01-02 12:16:56 +01:00 committed by GitHub
parent f3a6e073e2
commit 847367f51e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 51 additions and 45 deletions

4
Cargo.lock generated
View File

@ -1051,8 +1051,8 @@ dependencies = [
]
[[package]]
name = "timr"
version = "0.1.0"
name = "timr-tui"
version = "0.9.0"
dependencies = [
"clap",
"color-eyre",

View File

@ -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"

View File

@ -1,8 +1,6 @@
# tim:r
# timr-tui
**Pronounced `/ˈɪ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.
<img alt="menu" src="demo/menu.gif" />
</a>
# Args ⚙️
# CLI
```sh
Usage: timr [OPTIONS]
timr-tui --help
Usage: timr-tui [OPTIONS]
Options:
-c, --countdown <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
```

View File

@ -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

View File

@ -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)

View File

@ -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()

View File

@ -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<()> {