Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async #23

Merged
merged 221 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
221 commits
Select commit Hold shift + click to select a range
f3a582d
new: Initial commit πŸŽ‰
kdheepak Jun 17, 2023
4a1bf5c
Update README.md
kdheepak Jun 17, 2023
8391371
feat: tokio sleep ✨
kdheepak Jun 18, 2023
d8d626c
feat: remove async for increment and decrement ✨
kdheepak Jun 18, 2023
4f404d6
feat: decrease complexity of app struct ✨
kdheepak Jun 18, 2023
516f9ee
feat: remove ActionHandler ✨
kdheepak Jun 18, 2023
225ca88
docs: Update README.md πŸ“š
kdheepak Jun 18, 2023
2a29859
feat: More simplifications ✨
kdheepak Jun 18, 2023
15ea724
feat: Add Error event ✨
kdheepak Jun 18, 2023
517c05a
feat: Add trace_dbg macro ✨
kdheepak Jun 18, 2023
07b97c5
Create Makefile.toml
kdheepak Jun 19, 2023
e582a1a
Create rustfmt.toml
kdheepak Jun 19, 2023
659eafb
Create cd.yml
kdheepak Jun 19, 2023
a81499f
Create .gitkeep
kdheepak Jun 19, 2023
5dc2d7a
Update README.md
kdheepak Jun 19, 2023
8cea84a
feat: keypress should not delay tick ✨
kdheepak Jun 19, 2023
42c47bd
feat: Remove async trait ✨
kdheepak Jun 19, 2023
33911f2
docs: Update README.md πŸ“š
kdheepak Jun 19, 2023
98dfb59
feat: More simplifications ✨
kdheepak Jun 19, 2023
ec0d1cc
feat: Add time delay ✨
kdheepak Jun 19, 2023
079026c
feat: Tick after every increment or decrement ✨
kdheepak Jun 19, 2023
ec850d3
feat: Use ActionHandler ✨
kdheepak Jun 19, 2023
05aa584
feat: Change time sleep to 5 seconds ✨
kdheepak Jun 19, 2023
161b351
feat: Change tick rate to 50 ✨
kdheepak Jun 19, 2023
2c1b1b0
feat: Separate render loop ✨
kdheepak Jun 19, 2023
ce382e6
feat: Decrease logging of Tick ✨
kdheepak Jun 19, 2023
e7abd7b
feat: Replace RwLock with action channel implementation ✨
kdheepak Jun 19, 2023
85922f7
chore: reformat ♻️
kdheepak Jun 19, 2023
3a9e1f1
feat: Add ExitProcessing ✨
kdheepak Jun 19, 2023
1a758ef
feat: Add event handler tokio task ✨
kdheepak Jun 19, 2023
0547c9a
feat: Remove action handler and make more tokio tasks ✨
kdheepak Jun 19, 2023
2f29f9d
feat: Cleaner exit ✨
kdheepak Jun 19, 2023
2e069b8
feat: Better variable names ✨
kdheepak Jun 19, 2023
15d3ac7
feat: Refactor tx and rx for Action ✨
kdheepak Jun 19, 2023
a55352b
feat: Add build.rs with shadow ✨
kdheepak Jun 19, 2023
72eb225
feat: Update version string ✨
kdheepak Jun 19, 2023
20c0606
feat: Reorganize utils ✨
kdheepak Jun 19, 2023
898b0d9
feat: Use libc exit codes ✨
kdheepak Jun 19, 2023
ebf4699
feat: Use precommit config ✨
kdheepak Jun 19, 2023
78beb4e
style: Make clippy happy πŸ’Ž
kdheepak Jun 19, 2023
8ec0b46
refactor: move version to main.rs πŸ“¦
kdheepak Jun 19, 2023
709d915
feat: Drop shadow ✨
kdheepak Jun 19, 2023
0d8c5ec
feat: Update build.rs ✨
kdheepak Jun 19, 2023
1033336
feat: Update main.rs ✨
kdheepak Jun 19, 2023
35b483c
feat: Add cliff.toml ✨
kdheepak Jun 19, 2023
60e2648
feat: Simplify ✨
kdheepak Jun 20, 2023
06a1d8d
feat: Remove current_exe_path ✨
kdheepak Jun 20, 2023
820d3f9
feat: Rename tui.rs to terminal.rs ✨
kdheepak Jun 20, 2023
651ba92
feat: Rename TuiHandler to TerminalHandler ✨
kdheepak Jun 20, 2023
f583dc6
feat: Rename task to handle ✨
kdheepak Jun 20, 2023
93fa808
feat: Reorder import ✨
kdheepak Jun 20, 2023
755feb4
docs: Update README.md πŸ“š
kdheepak Jun 20, 2023
f00d172
feat: Add signal handler to suspend and resume ✨
kdheepak Jun 21, 2023
9c653a9
feat: Reduce CPU utilization to 5% ✨
kdheepak Jun 22, 2023
ea80ec9
feat: Rename TuiMsg to Message ✨
kdheepak Jun 22, 2023
997549f
chore: rename variables ♻️
kdheepak Jun 22, 2023
27b6195
feat: Separate app tick rate and render tick rate ✨
kdheepak Jun 22, 2023
66d9587
chore: rename variables ♻️
kdheepak Jun 22, 2023
73ff5d4
docs: Update README.md πŸ“š
kdheepak Jun 23, 2023
fe00905
chore: Rename variables ♻️
kdheepak Jun 23, 2023
c01c916
fix: bug in tick rate interval in event πŸ›
kdheepak Jun 23, 2023
add5fd3
feat: Add docs ✨
kdheepak Jul 8, 2023
6866b71
docs: Update index.qmd πŸ“š
kdheepak Jul 8, 2023
c41132e
docs: Update part1.qmd πŸ“š
kdheepak Jul 8, 2023
42e4d54
docs: Update tutorial πŸ“š
kdheepak Jul 9, 2023
411436b
docs: Update part2.qmd πŸ“š
kdheepak Jul 9, 2023
da1ae02
docs: Update part3.qmd πŸ“š
kdheepak Jul 10, 2023
3804051
docs: Update parts πŸ“š
kdheepak Jul 11, 2023
644967c
docs: Update tutorial πŸ“š
kdheepak Jul 11, 2023
bfad697
feat: Use terminal.rs and event.rs ✨
kdheepak Jul 13, 2023
861ae48
docs: Update tutorial πŸ“š
kdheepak Jul 13, 2023
34b88f4
feat: Use tokio::sync::Notify instead of oneshot::Sender<()> ✨
kdheepak Jul 15, 2023
6e5d14d
feat: Fix cargo clippy ✨
kdheepak Jul 15, 2023
fc22b62
feat: Use tokio_util::sync::CancellationToken instead of tokio::sync:…
kdheepak Jul 15, 2023
97f87f1
feat: Use Message::Suspend ✨
kdheepak Jul 15, 2023
5f64e45
feat: Use action::Action ✨
kdheepak Jul 15, 2023
2c6c4dc
feat: Move should_quit and should_suspend to root app ✨
kdheepak Jul 15, 2023
2591014
feat: Use TuiTask and EventTask ✨
kdheepak Jul 16, 2023
7ed8635
feat: Make methods on app private ✨
kdheepak Jul 16, 2023
3788901
feat: Add TuiTask methods ✨
kdheepak Jul 16, 2023
1c21c10
feat: Refactor TerminalHandlerTask and EventHandlerTask to separate f…
kdheepak Jul 16, 2023
75dfbeb
feat: Use tx.clone().unwrap() in home ✨
kdheepak Jul 17, 2023
6dc91b5
docs: Update tutorial πŸ“š
kdheepak Jul 17, 2023
28fd469
feat: Simplify app.run ✨
kdheepak Jul 18, 2023
483d8c6
feat: Simplify event and terminal ✨
kdheepak Jul 18, 2023
d85cfb2
docs: Update tutorial πŸ“š
kdheepak Jul 18, 2023
0834bf2
feat: Make get_data_dir and get_config_dir return Result<PathBuf> ins…
kdheepak Jul 18, 2023
0ce799c
feat: Fix naming ✨
kdheepak Jul 18, 2023
cd6f5a7
feat: Implement Deref for Tui ✨
kdheepak Jul 18, 2023
c8d01f5
docs: Update tutorial πŸ“š
kdheepak Jul 18, 2023
b5b2aa5
docs: Add faq πŸ“š
kdheepak Jul 22, 2023
3929ed3
docs: Update faq πŸ“š
kdheepak Jul 22, 2023
4be8107
chore: Update files ♻️
kdheepak Aug 17, 2023
f6ea147
fix: event documentation πŸ›
kdheepak Aug 18, 2023
3a2f8c9
feat: Remove on_*_event functions ✨
kdheepak Aug 18, 2023
7a4bf1d
feat: Add serde ✨
kdheepak Aug 20, 2023
3920039
chore: Update files ♻️
kdheepak Aug 20, 2023
e300cf5
feat: Rename from ratatui-template to ratatui-async-template ✨
kdheepak Aug 20, 2023
cb09789
fix: link πŸ›
kdheepak Aug 20, 2023
6121b45
docs: Update documentation πŸ“š
kdheepak Aug 20, 2023
d6e5d78
docs: Update documentation πŸ“š
kdheepak Aug 20, 2023
460ca28
docs: Update documentation πŸ“š
kdheepak Aug 20, 2023
b2ac1e1
docs: Update documentation πŸ“š
kdheepak Aug 20, 2023
2590917
docs: Use mdbook instead πŸ“š
kdheepak Aug 21, 2023
51b1fd5
docs: Add catppuccin πŸ“š
kdheepak Aug 21, 2023
cea7cb6
docs: Add linkcheck πŸ“š
kdheepak Aug 21, 2023
ebd2b99
docs: Fix CI πŸ“š
kdheepak Aug 21, 2023
d3faba1
docs: Disable playground πŸ“š
kdheepak Aug 21, 2023
f9f2f15
docs: Update github workflow πŸ“š
kdheepak Aug 21, 2023
e41afdc
docs: Update documentation πŸ“š
kdheepak Aug 21, 2023
79539b3
docs: Update documentation πŸ“š
kdheepak Aug 21, 2023
6ba1d70
docs: Make CI mdbook plugins install faster πŸ“š
kdheepak Aug 21, 2023
03136b5
docs: Use cache πŸ“š
kdheepak Aug 21, 2023
d63f079
docs: Better permissions on github πŸ“š
kdheepak Aug 21, 2023
d667362
chore: Add workflow dispatch ♻️
kdheepak Aug 21, 2023
f47edaa
chore: Remove catppuccin mdbook plugin install from ci ♻️
kdheepak Aug 21, 2023
6adde62
chore: Add bin to cargo cache ♻️
kdheepak Aug 21, 2023
7a46f6a
Update docs.yml
kdheepak Aug 21, 2023
3579983
chore: Update cache ♻️
kdheepak Aug 21, 2023
af8b16b
chore: Update docs.yml ♻️
kdheepak Aug 21, 2023
6021910
chore: Update docs.yml ♻️
kdheepak Aug 21, 2023
eda6b3c
chore: Update docs.yml ♻️
kdheepak Aug 21, 2023
ac67652
chore: Update docs.yml ♻️
kdheepak Aug 21, 2023
d8acebc
docs: add site-url for mdbook πŸ“š
kdheepak Aug 21, 2023
a10076a
docs: fix content on ci πŸ“š
kdheepak Aug 21, 2023
2b98c4f
docs: Fix sentence πŸ“š
kdheepak Aug 21, 2023
fad2a17
docs: fix 01-structure πŸ“š
kdheepak Aug 21, 2023
54a6c52
docs: Fix 01-structure πŸ“š
kdheepak Aug 21, 2023
1b25dae
docs: Add KeyEventPress example πŸ“š
kdheepak Aug 21, 2023
aa5098c
chore: Cache binaries for mdbook on CI ♻️
kdheepak Aug 21, 2023
bd55cdd
Update 01-structure.md
kdheepak Aug 21, 2023
fc77c63
docs: update structure
kdheepak Aug 21, 2023
0063756
docs: Update main.rs book section
kdheepak Aug 21, 2023
dac12b7
docs: Update action.rs
kdheepak Aug 21, 2023
c35904f
docs: Update index.qmd
kdheepak Aug 21, 2023
03047e6
docs: Rename files
kdheepak Aug 21, 2023
93af803
feat: Remove copy trait ✨
kdheepak Aug 22, 2023
5ab0514
Merge pull request #2 from ratatui-org/remove-copy-trait
kdheepak Aug 22, 2023
7011529
feat: Add rust toolchain ✨
kdheepak Aug 22, 2023
9b94ea2
feat: Use if let ✨
kdheepak Aug 22, 2023
f5c86d4
Update 04-structure.md
kdheepak Aug 29, 2023
868b8ab
feat: Use color eyre ✨
kdheepak Sep 10, 2023
81c550a
Merge pull request #3 from ratatui-org/use-color-eyre-human-panic
kdheepak Sep 10, 2023
0027a25
fix: Remove is_markdown_file function πŸ›
kdheepak Sep 10, 2023
c07e66e
docs: Update about string πŸ“š
kdheepak Sep 10, 2023
a99921c
feat: Use a simpler structure
kdheepak Sep 10, 2023
617f69d
Merge pull request #4 from ratatui-org/simplify
kdheepak Sep 11, 2023
d9f0162
chore: Remove cliff.toml ♻️
kdheepak Sep 11, 2023
55e91f2
feat: Don't use RUST_LOG environment variable ✨
kdheepak Sep 11, 2023
3cd85a3
feat: better error handling ✨
kdheepak Sep 11, 2023
2300826
Merge pull request #5 from ratatui-org/better-error-handling
kdheepak Sep 11, 2023
c3be3a0
docs: Update screenshot in README.md
kdheepak Sep 11, 2023
a47dbe4
docs: Update README text πŸ“š
kdheepak Sep 11, 2023
d2b84a9
docs: Remove tui-logger πŸ“š
kdheepak Sep 11, 2023
4c085fb
feat: Add default keymap ✨
kdheepak Sep 11, 2023
c7376fd
Merge pull request #7 from ratatui-org/add-default-keymap
kdheepak Sep 11, 2023
9e41105
chore: Change components/mod.rs to components.rs ♻️
kdheepak Sep 11, 2023
cb645ba
feat: Add FpsCounter component ✨
kdheepak Sep 14, 2023
60990b9
feat: Better logging ✨
kdheepak Sep 14, 2023
7aad514
feat: better error reporting ✨
kdheepak Sep 17, 2023
7b70d6d
feat: Use tick rate and frame rate ✨
kdheepak Sep 19, 2023
26e0402
feat: Add register action handler ✨
kdheepak Sep 19, 2023
2117603
fix: Change F1 to f1 to key event to string πŸ›
kdheepak Sep 19, 2023
4e96ac9
feat: Add test for key event to string ✨
kdheepak Sep 19, 2023
d4adf3b
docs: Fix include πŸ“š
kdheepak Sep 20, 2023
f67793e
feat: Add cargo generate template ✨
kdheepak Sep 28, 2023
8a38a41
docs: Update README.md πŸ“š
kdheepak Sep 28, 2023
cf01420
docs: Update README.md and index.md πŸ“š
kdheepak Sep 28, 2023
d39ba43
chore: Update ci.yml ♻️
kdheepak Sep 28, 2023
7a49593
feat: Update template for ratatui-counter ✨
kdheepak Sep 28, 2023
a53d776
docs: Update documentation πŸ“š
kdheepak Sep 28, 2023
42d8506
feat: Remove Cargo files from root ✨
kdheepak Sep 28, 2023
0556a94
docs: Better documentation for configuration πŸ“š
kdheepak Sep 28, 2023
3a975c5
feat: Add .envrc ✨
kdheepak Sep 28, 2023
264cd90
feat: Add .envrc ✨
kdheepak Sep 28, 2023
1096d48
docs: Update instructions for running demo πŸ“š
kdheepak Sep 28, 2023
f31e5fe
feat: Better configuration handling ✨
kdheepak Sep 28, 2023
b3fd991
feat: Better configuration handling in counter ✨
kdheepak Sep 28, 2023
b4a762e
docs: Update README.md πŸ“š
kdheepak Sep 28, 2023
9f3671e
Update README.md
kdheepak Sep 28, 2023
e666269
feat: Update styling ✨
kdheepak Sep 28, 2023
8a9fdc6
feat: Show current key presses ✨
kdheepak Sep 28, 2023
e9afa96
feat: Make cli.rs use short and long args ✨
kdheepak Sep 28, 2023
9a8a99b
docs: Update README.md
kdheepak Sep 28, 2023
efb69da
docs: Update README.md πŸ“š
kdheepak Sep 28, 2023
0848f11
feat: Update version string ✨
kdheepak Sep 28, 2023
a213044
feat: Add authors to the template ✨
kdheepak Sep 28, 2023
68fa335
feat: Add ci and cd to template ✨
kdheepak Sep 28, 2023
19191c4
feat: Better authors and package name ✨
kdheepak Sep 28, 2023
af62e44
feat: Ignore log files ✨
kdheepak Sep 28, 2023
79dcaaf
feat: Add more crossterm feature support ✨
kdheepak Sep 30, 2023
dd5827f
feat: Make tui build constructors ✨
kdheepak Oct 2, 2023
59ee5a4
feat: Move mode to separate file ✨
kdheepak Oct 2, 2023
ca30983
docs: Update README.md
kdheepak Oct 2, 2023
c891d7e
docs: Update README.md πŸ“š
kdheepak Oct 2, 2023
662deb4
docs: Update README.md πŸ“š
kdheepak Oct 2, 2023
a54bc4d
docs: Update README.md πŸ“š
kdheepak Oct 2, 2023
875fc89
docs: Update documentation πŸ“š
kdheepak Oct 2, 2023
3cee72b
feat: Change default render rate to 4fps ✨
kdheepak Oct 2, 2023
74f8e6d
docs: Update README.md
kdheepak Oct 8, 2023
5b88616
feat: Use rhai script for cargo generate ✨
kdheepak Oct 8, 2023
e22f8ce
feat: Add source for rhai script ✨
kdheepak Oct 8, 2023
f66e1c8
feat: Change spelling ✨
kdheepak Oct 8, 2023
ea9ea84
feat: Better prompt message ✨
kdheepak Oct 8, 2023
fd7ab98
docs: Update README.md πŸ“š
kdheepak Oct 8, 2023
f46a190
docs: Add docstring in template πŸ“š
kdheepak Oct 14, 2023
a3eaf3b
feat: Add Fps component to template ✨
kdheepak Oct 21, 2023
60a02b9
feat: Add optional rustfmt.toml ✨
kdheepak Oct 21, 2023
aa70be2
docs: Update README.md πŸ“š
kdheepak Oct 21, 2023
bb886cc
docs: Update README.md πŸ“š
kdheepak Oct 21, 2023
625e64e
docs: Update README.md with better headings πŸ“š
kdheepak Oct 21, 2023
65ed9e6
docs: Update README.md for more clarity πŸ“š
kdheepak Oct 21, 2023
e1f67ca
docs: Update README.md by moving gifs around πŸ“š
kdheepak Oct 21, 2023
f8456d7
docs: Update README.md intro gif πŸ“š
kdheepak Oct 21, 2023
a5d6af9
docs: Update README.md
kdheepak Oct 22, 2023
682092a
docs: Update README.md
kdheepak Nov 4, 2023
ec63e8f
fix: Persist git info πŸ›
kdheepak Nov 4, 2023
c3ad880
feat: Use strum ✨ (#20)
kdheepak Dec 14, 2023
727a2b4
chore: Rename to async template ♻️ (#21)
kdheepak Dec 15, 2023
06718fc
Merge remote-tracking branch 'async/main'
joshka Dec 15, 2023
d4cb726
Update docs to make it relevant to both templates
joshka Dec 15, 2023
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
32 changes: 18 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,6 @@ This repository contains templates for bootstrapping a Rust
[`Ratatui`](https://github.com/ratatui-org/ratatui) &
[`crossterm`](https://github.com/crossterm-rs/crossterm).

## Project structure

```text
src/
β”œβ”€β”€ app.rs -> holds the state and application logic
β”œβ”€β”€ event.rs -> handles the terminal events (key press, mouse click, resize, etc.)
β”œβ”€β”€ handler.rs -> handles the key press events and updates the application
β”œβ”€β”€ lib.rs -> module definitions
β”œβ”€β”€ main.rs -> entry-point
β”œβ”€β”€ tui.rs -> initializes/exits the terminal interface
└── ui.rs -> renders the widgets / UI
```

## Creating a project

1. Install [`cargo-generate`](https://github.com/cargo-generate/cargo-generate#installation)
Expand All @@ -29,9 +16,26 @@ src/
2. Create a new app based on this repository:

```shell
cargo generate ratatui-org/ratatui-template simple
cargo generate ratatui-org/ratatui-template
```

3. Choose either the [Simple](#simple-template) or [Async](./async/README.md) template.

## Simple template

The simple template will create the following project structure:

```text
src/
β”œβ”€β”€ app.rs -> holds the state and application logic
β”œβ”€β”€ event.rs -> handles the terminal events (key press, mouse click, resize, etc.)
β”œβ”€β”€ handler.rs -> handles the key press events and updates the application
β”œβ”€β”€ lib.rs -> module definitions
β”œβ”€β”€ main.rs -> entry-point
β”œβ”€β”€ tui.rs -> initializes/exits the terminal interface
└── ui.rs -> renders the widgets / UI
```

## See also

- [Rust Munich Meetup #8 - Designing TUI Applications in Rust](https://www.youtube.com/watch?v=ogdJnOLo238)
Expand Down
31 changes: 31 additions & 0 deletions async/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Build Template
on:
push:
branches:
- main
pull_request:

jobs:
build:
runs-on: ubuntu-latest
env:
PROJECT_NAME: ratatui-github-example
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Run cargo generate
uses: cargo-generate/[email protected]
with:
name: ${{ env.PROJECT_NAME }}
subfolder: template
template_values_file: .github/workflows/template.toml
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
- name: Cargo check
# we need to move the generated project to a temp folder, away from the template project
# otherwise `cargo` runs would fail
# see https://github.com/rust-lang/cargo/issues/9922
run: |
mv $PROJECT_NAME ${{ runner.temp }}/
cd ${{ runner.temp }}/$PROJECT_NAME
cargo check --tests
50 changes: 50 additions & 0 deletions async/.github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: docs

on:
push:
branches:
- main
pull_request:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
steps:
- uses: actions/checkout@v2

- name: Setup mdBook
uses: peaceiris/actions-mdbook@v1
with:
mdbook-version: "latest"

- uses: baptiste0928/cargo-install@v2
with:
crate: mdbook-admonish
version: "1.9.0"

- uses: baptiste0928/cargo-install@v2
with:
crate: mdbook-svgbob2
version: "0.3.0"

- uses: baptiste0928/cargo-install@v2
with:
crate: mdbook-linkcheck
version: "0.7.7"

- name: Build with mdbook
run: mdbook build book

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
if: github.ref == 'refs/heads/main'
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./book/book/html
force_orphan: true
7 changes: 7 additions & 0 deletions async/.github/workflows/template.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[values]
gh-username = "kdheepak"
project-description = "Example of ratatui template"
msrv = "stable"
use_gitserver = false
crossterm_io = "stderr"
use_rustfmt = false
18 changes: 18 additions & 0 deletions async/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Created by https://www.toptal.com/developers/gitignore/api/rust
# Edit at https://www.toptal.com/developers/gitignore?templates=rust

### Rust ###
# Generated by Cargo
# will have compiled files and executables
debug/
target/
/target
.data

# These are backup files generated by rustfmt
**/*.rs.bk

# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# End of https://www.toptal.com/developers/gitignore/api/rust
44 changes: 44 additions & 0 deletions async/.justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
default:
@just --list

fmt:
cargo fmt
prettier --write .
just --fmt --unstable

update:
cargo upgrade --incompatible
cargo update

check:
pre-commit run --all-files
cargo check
cargo clippy

build:
cargo build --all-targets

test:
cargo test run --workspace --all-targets

changelog:
git cliff -o CHANGELOG.md
prettier --write CHANGELOG.md

binary-name := "ratatui-hello-world"

generate-hello-world:
cargo generate --path . --name {{binary-name}} -d project-description="Hello World project using ratatui-template" -d gh-username=kdheepak -d msrv="stable"

generate:
@just clean
@just generate-hello-world

clean:
rm -rf {{binary-name}}

generate-and-run:
@just generate
cd {{binary-name}} && cargo run
@just clean

32 changes: 32 additions & 0 deletions async/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
default_stages: [commit]
default_install_hook_types: [pre-commit, commit-msg]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: check-json
- id: check-merge-conflict
- id: check-symlinks
- id: check-toml
- id: check-vcs-permalinks
- id: check-xml
- id: check-yaml
- id: destroyed-symlinks
- id: detect-private-key
- id: fix-byte-order-marker
- id: mixed-line-ending
- id: pretty-format-json
- id: trailing-whitespace
- repo: https://github.com/rhysd/actionlint
rev: v1.6.24
hooks:
- id: actionlint

ci:
autofix_prs: false
autoupdate_commit_msg: "chore: pre-commit autoupdate"
skip: [actionlint]
19 changes: 19 additions & 0 deletions async/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
Copyright (c) 2023 Dheepak Krishnamurthy

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
131 changes: 131 additions & 0 deletions async/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
# async-template

![async template demo](https://user-images.githubusercontent.com/1813121/277114001-0d25a09c-f24e-4ffc-8763-cd258828cec0.gif)

## Usage

You can start by using `cargo-generate`:

```shell
cargo install cargo-generate
cargo generate ratatui-org/templates async --name ratatui-hello-world
cd ratatui-hello-world
```

## Features

- Uses [tokio](https://tokio.rs/) for async events
- Start and stop key events to shell out to another TUI like vim
- Supports suspend signal hooks
- Logs using [tracing](https://github.com/tokio-rs/tracing)
- [better-panic](https://github.com/mitsuhiko/better-panic)
- [color-eyre](https://github.com/eyre/color-eyre)
- [human-panic](https://github.com/rust-cli/human-panic)
- Clap for command line argument parsing
- `Component` trait with
[`Home`](https://github.com/ratatui-org/async-template/blob/main/template/src/components/home.rs)
and
[`Fps`](https://github.com/ratatui-org/async-template/blob/main/template/src/components/fps.rs)
components as examples

## Advanced Usage

You can also use a
[`template.toml`](https://github.com/ratatui-org/async-template/blob/main/.github/workflows/template.toml)
file to skip the prompts:

```bash
$ 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
```

## Running your App

```bash
cargo run # Press `q` to exit
```

## Show help

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

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

```bash
$ 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
```

## Documentation

Read documentation on design decisions in the template here:
<https://ratatui-org.github.io/async-template/>

## Counter + Text Input Demo

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:

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

![counter demo](https://github.com/ratatui-org/async-template/assets/1813121/057a0fe9-9f6d-4f8c-963c-ca2725721bdd)
1 change: 1 addition & 0 deletions async/book/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
book
Loading
Loading