DEPRECATED: Use https://github.com/ratatui-org/templates instead
cargo generate ratatui-org/templates async
- Uses tokio for async events
- Start and stop key events to shell out to another TUI like vim
- Supports suspend signal hooks
- Logs using tracing
- better-panic
- color-eyre
- human-panic
- Clap for command line argument parsing
Component
trait withHome
andFps
components as examples
You can start by using cargo-generate
:
cargo install cargo-generate
cargo generate --git https://github.com/ratatui-org/async-template --name ratatui-hello-world
cd ratatui-hello-world
You can also use a
template.toml
file to skip the prompts:
$ cargo generate --git https://github.com/ratatui-org/async-template --template-values-file .github/workflows/template.toml --name ratatui-hello-world
# OR generate from local clone
$ cargo generate --path . --template-values-file .github/workflows/template.toml --name ratatui-hello-world
Run
cargo run # Press `q` to exit
Show help
$ cargo run -- --help
Hello World project using ratatui-template
Usage: ratatui-hello-world [OPTIONS]
Options:
-t, --tick-rate <FLOAT> Tick rate, i.e. number of ticks per second [default: 1]
-f, --frame-rate <FLOAT> Frame rate, i.e. number of frames per second [default: 60]
-h, --help Print help
-V, --version Print version
Show version
Without direnv variables:
$ cargo run -- --version
Finished dev [unoptimized + debuginfo] target(s) in 0.07s
Running `target/debug/ratatui-hello-world --version`
ratatui-hello-world v0.1.0-47-eb0a31a
Authors: Dheepak Krishnamurthy
Config directory: /Users/kd/Library/Application Support/com.kdheepak.ratatui-hello-world
Data directory: /Users/kd/Library/Application Support/com.kdheepak.ratatui-hello-world
With direnv variables:
$ direnv allow
direnv: loading ~/gitrepos/async-template/ratatui-hello-world/.envrc
direnv: export +RATATUI_HELLO_WORLD_CONFIG +RATATUI_HELLO_WORLD_DATA +RATATUI_HELLO_WORLD_LOG_LEVEL
$ # OR
$ export RATATUI_HELLO_WORLD_CONFIG=`pwd`/.config
$ export RATATUI_HELLO_WORLD_DATA=`pwd`/.data
$ export RATATUI_HELLO_WORLD_LOG_LEVEL=debug
$ cargo run -- --version
Finished dev [unoptimized + debuginfo] target(s) in 0.07s
Running `target/debug/ratatui-hello-world --version`
ratatui-hello-world v0.1.0-47-eb0a31a
Authors: Dheepak Krishnamurthy
Config directory: /Users/kd/gitrepos/async-template/ratatui-hello-world/.config
Data directory: /Users/kd/gitrepos/async-template/ratatui-hello-world/.data
Read documentation on design decisions in the template here: https://ratatui-org.github.io/async-template/
This repo contains a ratatui-counter
folder that is a working demo as an example. If you wish to
run a demo without using cargo generate
, you can run the counter + text input demo by following
the instructions below:
git clone https://github.com/ratatui-org/async-template
cd async-template
cd ratatui-counter # counter + text input demo
export RATATUI_COUNTER_CONFIG=`pwd`/.config
export RATATUI_COUNTER_DATA=`pwd`/.data
export RATATUI_COUNTER_LOG_LEVEL=debug
# OR
direnv allow
cargo run
You should see a demo like this: