Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Features

- (cli) Add `--tabata` argument [#208](https://github.com/sectore/timr-tui/pull/208)
- (pomodoro) auto-detect `Tabata` [#207](https://github.com/sectore/timr-tui/pull/207)
- (pomodoro) introduce `max rounds` to limit sessions [#205](https://github.com/sectore/timr-tui/pull/205), [#206](https://github.com/sectore/timr-tui/pull/206)
- (notification) detailed pomodoro status in system notification [#204](https://github.com/sectore/timr-tui/pull/204)
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ Options:
-c, --countdown <COUNTDOWN> Countdown time to start from. Formats: 'Yy Dd hh:mm:ss', 'Dd hh:mm:ss', 'Yy mm:ss', 'Dd mm:ss', 'Yy ss', 'Dd ss', 'hh:mm:ss', 'mm:ss', 'ss'. Examples: '1y 5d 10:30:00', '2d 4:00', '1d 10', '5:03'.
-w, --work <WORK> Work time to count down from. Formats: 'ss', 'mm:ss', 'hh:mm:ss'
-p, --pause <PAUSE> Pause duration. Single value (every round): '5:00'. Variable: 'regular,special[,every_n_rounds]' - special pause every N rounds, default every 4. Examples: '5:00,25:00' or '5:00,30:00,5'. Duration formats: 'ss', 'mm:ss', 'hh:mm:ss'.
--auto-switch Enable auto-switch between `work` and `pause` screens.
--max-rounds <MAX_ROUNDS> Maximum number of pomodoro rounds. 0 = unlimited.
--tabata Tabata regimen: work 20s, pause 10s, 8 rounds, auto-switch enabled.
--auto-switch Enable auto-switch between `work` and `pause` screens.
-e, --event <EVENT> Event date time and title (optional). Format: 'YYYY-MM-DD HH:MM:SS' or 'time=YYYY-MM-DD HH:MM:SS[,title=...]'. Examples: '2025-10-10 14:30:00' or 'time=2025-10-10 14:30:00,title=My Event'.
-d, --decis Show deciseconds.
-m, --mode <MODE> Mode to start with. [possible values: countdown, timer, pomodoro, event, localtime]
Expand Down
24 changes: 15 additions & 9 deletions src/app.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::{
args::Args,
common::{AppEditMode, AppTime, AppTimeFormat, ClockTypeId, Content, Style, Toggle},
constants::TICK_VALUE_MS,
constants::{TABATA_MAX_ROUNDS, TABATA_PAUSE, TABATA_WORK, TICK_VALUE_MS},
event::Event,
events::{self, TuiEventHandler},
storage::AppStorage,
Expand Down Expand Up @@ -105,8 +105,15 @@ impl From<FromAppArgs> for App {
fn from(args: FromAppArgs) -> Self {
let FromAppArgs { args, stg, app_tx } = args;

let is_pause_from_args = args.pause.is_some();
let pause_duration = args.pause.unwrap_or(stg.pause_duration);
let work_from_args = args.tabata.then_some(TABATA_WORK).or(args.work);
let pause_from_args = args
.tabata
.then_some(PauseDuration::Fixed(TABATA_PAUSE))
.or(args.pause);
let max_rounds_from_args = args.tabata.then_some(TABATA_MAX_ROUNDS).or(args.max_rounds);

let is_pause_from_args = pause_from_args.is_some();
let pause_duration = pause_from_args.unwrap_or(stg.pause_duration);
let current_value_pause = if is_pause_from_args {
pause_duration.for_round(stg.pomodoro_count)
} else {
Expand All @@ -125,7 +132,7 @@ impl From<FromAppArgs> for App {
Some(mode) => mode,
// check other args (especially durations)
None => {
if args.work.is_some() || is_pause_from_args {
if work_from_args.is_some() || is_pause_from_args {
Content::Pomodoro
} else if args.countdown.is_some() {
Content::Countdown
Expand All @@ -141,15 +148,14 @@ impl From<FromAppArgs> for App {
style: args.style.unwrap_or(stg.style),
pomodoro_mode: stg.pomodoro_mode,
pomodoro_round: stg.pomodoro_count,
pomodoro_auto_switch: args.auto_switch || stg.pomodoro_auto_switch,
pomodoro_max_rounds: args
.max_rounds
pomodoro_auto_switch: args.auto_switch || args.tabata || stg.pomodoro_auto_switch,
pomodoro_max_rounds: max_rounds_from_args
// 0 -> resets `max_rounds`
.and_then(|n| (n > 0).then_some(n))
.or(stg.pomodoro_max_rounds),
initial_value_work: args.work.unwrap_or(stg.inital_value_work),
initial_value_work: work_from_args.unwrap_or(stg.inital_value_work),
// invalidate `current_value_work` if an initial value is set via args
current_value_work: args.work.unwrap_or(stg.current_value_work),
current_value_work: work_from_args.unwrap_or(stg.current_value_work),
pause_duration,
current_value_pause,
initial_value_countdown: args.countdown.unwrap_or(stg.inital_value_countdown),
Expand Down
6 changes: 6 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,12 @@ pub struct Args {
#[arg(long, help = "Maximum number of pomodoro rounds. 0 = unlimited.")]
pub max_rounds: Option<u64>,

#[arg(
long,
help = "Tabata regimen: work 20s, pause 10s, 8 rounds, auto-switch enabled."
)]
pub tabata: bool,

#[arg(long, help = "Enable auto-switch between `work` and `pause` screens.")]
pub auto_switch: bool,

Expand Down
Loading