captain/README.md
2023-04-17 19:37:00 +01:00

45 lines
1.5 KiB
Markdown

# Captain
Captain is a simple tool for creating interactive command line lessons.
## Usage
Captain makes use of a `config.toml` file which contains all the exercises for a single lesson. The current progress of the lesson is stored in the `state.toml` file.
### Commands
- **`captain`/`captain view`** - View the current problem.
- **`captain hint`** - View the hint for the current problem.
- **`captain check`** - Run the current problem's check. If the check passes, captain will move onto the next problem.
- **`captain reset`** - Reset progress to the first problem.
### Creating a config
The config file should contain a `success_message` which is printed once everything has been completed, and multiple `problems` like so:
```toml
success_message = "Congrats!"
[[problem]]
text = "What colour is the sky?"
hint = "It rhymes with moo"
check_type = "ask"
check = "blue"
```
Each problem has the following fields:
| Field | Description |
| --- | --- |
| `text` | This is shown to the user to explain what to do. |
| `hint` | This is shown when the user runs `captain hint`. It should give a bit of help towards the answer. It can be left blank. |
| `check_type` | _See below_ |
| `check` | _See below_ |
#### Checks
There are multiple checks available:
* `ask` - This simply asks the user to type and answer and checks whether it equals whatever is in `check`.
* `ask_cmd` - This asks the user to type an answer and checks it against the output of the command from `check`.
* `cmd` - This runs the command in `check` and checks whether it is successful.