Skip to content

Commit 776d67c

Browse files
authored
feat: add interactive prompt for video generation (#298)
## Summary After finishing a recording, t-rec now prompts users to generate an MP4 video in addition to the GIF. This provides a convenient way to get both formats without needing to re-record or remember to pass `--video` upfront. The prompt runs in a background thread, so users can answer while the GIF is being generated - no wasted waiting time. ### User Experience After the GIF generation message appears, users see: ``` 🎉 🚀 Generating t-rec.gif 🎬 Also generate MP4 video? (y/n) › (auto-skip in 15s) ``` - Press `y` to generate MP4 (no Enter required) - Press `n` to skip (no Enter required) - Wait 15 seconds to auto-skip ### When the prompt is skipped - **Quiet mode** (`-q`): No prompt, respects automation needs - **Non-interactive** (piped input, CI): Returns "no" automatically - **Already requested video**: If `--video` or `--video-only` was used, video generates without prompting ### Implementation - Uses `dialoguer` crate for cross-platform terminal input handling - Prompt runs in background thread while GIF generates - 15-second countdown displayed below the prompt Closes #219 ## Test plan - [x] Run `t-rec`, wait for prompt, press `y` → video generated - [x] Run `t-rec`, wait for prompt, press `n` → no video - [x] Run `t-rec`, wait 15 seconds → timeout, no video - [x] Run `t-rec --video` → no prompt, video generated - [x] Run `t-rec --video-only` → no prompt, only video - [x] Run `t-rec -q` → no prompt (quiet mode) - [ ] Run `echo "" | t-rec` → no prompt (non-interactive) --------- Signed-off-by: Sven Kanoldt <sven@d34dl0ck.me>
1 parent d586965 commit 776d67c

File tree

8 files changed

+604
-10
lines changed

8 files changed

+604
-10
lines changed

Cargo.lock

Lines changed: 124 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ simplerand = "1.6"
2929
serde = { version = "1.0", features = ["derive"] }
3030
toml = "0.8"
3131
dirs = "5.0"
32+
dialoguer = { version = "0.11", default-features = false }
3233

3334
[dependencies.clap]
3435
version = "4.5"

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,29 @@ t-rec --fps 15
279279

280280
**Note:** Higher framerates produce larger files. The default 4 fps is recommended for most use cases.
281281

282+
### Video Generation
283+
284+
After recording, t-rec will ask if you also want to generate an MP4 video:
285+
286+
```
287+
🎉 🚀 Generating t-rec.gif
288+
289+
🎬 Also generate MP4 video? (y/n) ›
290+
(auto-skip in 15s)
291+
```
292+
293+
- Press `y` to generate both GIF and MP4
294+
- Press `n` or wait 15 seconds to skip
295+
296+
To always generate video without being asked, use the `--video` flag:
297+
298+
```sh
299+
t-rec --video # Generate both GIF and MP4
300+
t-rec --video-only # Generate only MP4, no GIF
301+
```
302+
303+
The prompt is skipped in quiet mode (`-q`) or non-interactive environments.
304+
282305
### Disable idle detection & optimization
283306

284307
If you are not happy with the idle detection and optimization, you can disable it with the `-n` or `--natural` parameter.

0 commit comments

Comments
 (0)