Conghao97's picture tcftrees's picture
ProgramGen release
d086025
|
Raw History Blame Contribute Delete
5.95 kB

rust-cli-pomodoro

A terminal Pomodoro timer that manages your time with customizable work and break periods, desktop/Slack/Discord notifications, and interactive or IPC-based control.

Demo

Demo

Features

  • Create notifications with customized work and break time.
  • When a configuration file is given, notifications use default values from it.
  • Queue notifications; a queued notification starts after previously registered ones finish.
  • Customize notification delivery channels (see "Using configuration.json" below).
  • Pretty-print created notifications with the list command.
  • Delete registered notification(s).
  • Track archived notification(s) with the history command.
  • Delete archived notifications with history --clear.
  • Clear the terminal.
  • Command history look-up with arrow keys in interaction mode.
  • Generate auto-completion scripts for several shells (fish, zsh, bash, elvish, powershell).

A "notification" consists of a work time and a break time. Pomodoro manages timers using "notifications".

Command-line usage

Pomodoro supports two input types: standard input (interactive) and IPC (via a unix domain socket). Commands differ slightly depending on the input type.

Start up & IPC command

Start up by running pomodoro with the appropriate OPTIONS, or send a command to an already-running instance via IPC using a SUBCOMMAND.

pomodoro 1.4.0
start up application with config or run command using uds client

Usage: pomodoro [OPTIONS]
       pomodoro <COMMAND>

Commands:
  create      create the notification
  queue       create the notification
  delete      delete a notification
  list        list notifications
  history     show archived notifications
  test        test notification
  completion  generate completions for shells
  help        Print this message or the help of the given subcommand(s)

Options:
  -c, --config <config>  Read configuration json file from this path
  -h, --help             Print help
  -V, --version          Print version

Standard input (interactive) command

While pomodoro is running, you can interactively issue commands.

pomodoro 1.4.0
manage your time!

Usage: pomodoro [COMMAND]

Commands:
  create   create the notification
  queue    create the notification
  delete   delete a notification
  list     list notifications
  history  show archived notifications
  test     test notification
  clear    clear terminal
  exit     exit pomodoro app
  help     Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

Subcommand reference

create / queue

Create (or queue) a notification.

  • -w, --work <value> — focus time in minutes. If omitted, the value is taken from work_time_default_value in the configuration file; if unavailable, 25 is used.
  • -b, --break <value> — break time in minutes. If omitted, the value is taken from break_time_default_value in the configuration file; if unavailable, 5 is used.
  • -d, --default — create a notification using the default work/break values from the configuration file (or 25/5 if absent). Conflicts with --work and --break.

delete

Delete a notification.

  • -i, --id <id> — the ID of the notification to delete.
  • -a, --all — delete all notifications.

list

List notifications.

  • -p — show work-time completion percentage.

history

Show archived notifications.

  • -c, --clear — delete all notifications from history.

test

Send a test notification.

completion

Generate completion scripts for shells.

Usage: pomodoro completion [shell]

Arguments:
  [shell]  [possible values: fish, zsh, bash, elvish, powershell]

Installation

Clone the repository and run:

git clone git@github.com:24seconds/rust-cli-pomodoro.git
cd rust-cli-pomodoro
cargo run --release

Or install with cargo:

cargo install rust-cli-pomodoro

Using configuration.json

Pomodoro supports several configuration options:

  • Slack notification
  • Discord notification
  • Default work time value
  • Default break time value

Create a JSON file (for example configuration.json) with the following shape:

{
  "slack": {
      "token": "your-bot-token-string",
      "channel": "your-slack-channel-id"
  },
  "discord": {
      "webhook_url": "your-webhook-url"
  },
  "work_time_default_value": 30,
  "break_time_default_value": 10
}

Run pomodoro with the configuration file:

# If the configuration.json file exists in the current path
pomodoro --config ./configuration.json

Auto completion

rust-cli-pomodoro supports tab completion. Generate the completion script manually and place it in the appropriate shell path.

Auto completion example

Step 1. Generate the completion script file

Usage: pomodoro completion [shell]

Arguments:
  [shell]  [possible values: fish, zsh, bash, elvish, powershell]

For example, for zsh:

$ pomodoro completion zsh > _pomodoro

The file name should be underscore + binary name, i.e. _pomodoro.

Step 2. Put the completion script file in the proper path

For zsh, the proper path is one of the directories in $fpath:

> echo $fpath

For example, /Users/young/.oh-my-zsh/completions.

Step 3. Reload the shell

$ exec zsh
# or
$ source ~/.zshrc

Newly opened terminals will work without this step.

Compatibility

  • Start up & standard input: depends on notify-rust; supports Linux, macOS (<= 11.0.0), and Windows (10, 8.1).
  • IPC: Linux and macOS (pomodoro uses a unix domain socket).