Skip to content

Commit

Permalink
Update docs to make it relevant to both templates
Browse files Browse the repository at this point in the history
  • Loading branch information
joshka committed Dec 15, 2023
1 parent 06718fc commit d4cb726
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 33 deletions.
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
38 changes: 20 additions & 18 deletions async/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
# async-template

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

### Features
## 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
Expand All @@ -18,15 +28,7 @@
[`Fps`](https://github.com/ratatui-org/async-template/blob/main/template/src/components/fps.rs)
components as examples

### Usage

You can start by using `cargo-generate`:

```bash
$ cargo install cargo-generate
$ cargo generate --git https://github.com/ratatui-org/async-template --name ratatui-hello-world
$ cd ratatui-hello-world
```
## Advanced Usage

You can also use a
[`template.toml`](https://github.com/ratatui-org/async-template/blob/main/.github/workflows/template.toml)
Expand All @@ -38,13 +40,13 @@ $ cargo generate --git https://github.com/ratatui-org/async-template --template-
$ cargo generate --path . --template-values-file .github/workflows/template.toml --name ratatui-hello-world
```

**Run**
## Running your App

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

**Show `help`**
## Show help

```bash
$ cargo run -- --help
Expand All @@ -59,7 +61,7 @@ Options:
-V, --version Print version
```

**Show `version`**
## Show `version`

Without direnv variables:

Expand Down Expand Up @@ -99,12 +101,12 @@ Config directory: /Users/kd/gitrepos/async-template/ratatui-hello-world/.config
Data directory: /Users/kd/gitrepos/async-template/ratatui-hello-world/.data
```

### Documentation
## Documentation

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

### Counter + Text Input Demo
## 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
Expand All @@ -126,4 +128,4 @@ cargo run

You should see a demo like this:

![](https://github.com/ratatui-org/async-template/assets/1813121/057a0fe9-9f6d-4f8c-963c-ca2725721bdd)
![counter demo](https://github.com/ratatui-org/async-template/assets/1813121/057a0fe9-9f6d-4f8c-963c-ca2725721bdd)
2 changes: 1 addition & 1 deletion cargo-generate.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# configuration for https://cargo-generate.github.io/cargo-generate/

[template]
sub_templates = ["simple"]
sub_templates = ["simple", "async"]

0 comments on commit d4cb726

Please sign in to comment.