File size: 5,948 Bytes
d086025
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
# 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](assets/pomodoro_demo.gif)

## 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:

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

Or install with cargo:

```sh
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:

```json
{
  "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
}
```

- Slack notifications use the [chat.PostMessage API](https://api.slack.com/methods/chat.postMessage).
- Discord notifications use a [webhook URL](https://discord.com/developers/docs/resources/webhook).

Run pomodoro with the configuration file:

```sh
# 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](assets/auto_completion_example.png)

### Step 1. Generate the completion script file

```sh
Usage: pomodoro completion [shell]

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

For example, for zsh:

```sh
$ 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`:

```sh
> echo $fpath
```

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

### Step 3. Reload the shell

```sh
$ exec zsh
# or
$ source ~/.zshrc
```

Newly opened terminals will work without this step.

## Compatibility

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