https://github.com/rytswd/cli-demo-helper
CLI demo made easier
https://github.com/rytswd/cli-demo-helper
bash cli shell
Last synced: 9 months ago
JSON representation
CLI demo made easier
- Host: GitHub
- URL: https://github.com/rytswd/cli-demo-helper
- Owner: rytswd
- License: mit
- Created: 2021-07-31T21:42:20.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-06-09T17:53:34.000Z (about 4 years ago)
- Last Synced: 2024-11-14T23:36:59.270Z (over 1 year ago)
- Topics: bash, cli, shell
- Language: Shell
- Homepage:
- Size: 8.32 MB
- Stars: 4
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# CLI Demo Helper
## 🚀 Examples

> Ref: [example-minimal.sh](/example-minimal.sh) file used in above example
```bash
#!/usr/bin/env bash
# shellcheck source=./demo-helper.sh
source "$(dirname "$0")/demo-helper.sh"
comment "Starting demo with demo-helper..."
execute "ls -la"
comment_r "Special characters are written as is, such as '\\~!!@(*#@)"
comment_g "It is simple to use, you just need to source the helper script."
comment_b "No extra tool needed."
comment "End of demo!"
```
## ✨ Usage
You need to `source` the `demo-helper.sh` file, and use provided functions.
The simplest approach is to copy the `demo-helper.sh` file to your local, by running something like below.
```bash
curl -sSL https://raw.githubusercontent.com/rytswd/cli-demo-helper/main/demo-helper.sh \
> demo-helper.sh
```
With that, you can have the following snippet in your shell script to set up functions.
```bash
# shellcheck source=./demo-helper.sh
source "$(dirname "$0")/demo-helper.sh"
```
## 🎮 Functions
| Function | Description |
| ------------------------ | ---------------------------------------------------------- |
| `comment "abc"` | Write comment like string, with preceding character of `#` |
| `comment_r "abc"` | Write comment the same way, with red text |
| `comment_g "abc"` | Write comment the same way, with green text |
| `comment_b "abc"` | Write comment the same way, with blue text |
| `comment_w "abc"` | Write comment the same way, with white text |
| `execute "some_command"` | Write string as command, and execute by `eval` |
## 🧩 Supported Variables
| Function | Description | Default |
| ------------------------ | ------------------------------------------------- | -------------- |
| `demo_helper_type_speed` | Imitated type speed in character-per-min notation | 1200 |
| `demo_helper_prompt` | Prompt for each line like `PS1` | `$ ` in yellow |