Skip to content

Commit

Permalink
docs: add quick start
Browse files Browse the repository at this point in the history
  • Loading branch information
shuta13 committed Apr 18, 2024
1 parent fcb20f1 commit 7f045f9
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 5 deletions.
54 changes: 49 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,66 @@ npm install -g moldable

## Quick Start

Create a `.moldable` folder in the root directory of your application, and create Markdown file within it shown below.
Create a `.moldable` folder in the root directory of your application, and create Markdown file within it shown below. Name the file `quick-start.md`.

```md
````md
---
name: "quick-start"
description: "Quick Start"
prompts:
- type: "base"
name: "name"
message: "Type your name"
validate: "{{if eq (len .input) 0}}Name must have more than - characters{{end}}"
- type: "select"
name: "favoriteColor"
message: "Select your favorite color"
choices:
- "Red"
- "Green"
- "Blue"
actions:
- type: "add"
path: "src/quick-start.json"
template: "quick-start.json"
---

# quick-start.json

```json
{
"name": "{{.name}}",
"favoriteColor": "{{.favoriteColor}}"
}
```
````

Execute `moldable` in the root directory of your application, and select the Generator you want to use.

```bash
# Answer the questions
? Select Generator:
▸ quick-start - Quick Start

```
✔ Type your name : John Doe█

Answer the questions that appear, and the code will be generated.
? Select your favorite color :
▸ Red
Green
Blue

```bash
# Results
🖨 Added:
src/quick-start.json
```

Answer the questions that appear, and the code will be generated in the `quick-start.json` file.

```json
{
"name": "John Doe",
"favoriteColor": "Red"
}
```

## Advanced Usage
Expand Down
29 changes: 29 additions & 0 deletions __mocks__/.moldable/quick-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
name: "quick-start"
description: "Quick Start"
prompts:
- type: "base"
name: "name"
message: "Type your name"
validate: "{{if eq (len .input) 0}}Name must have more than - characters{{end}}"
- type: "select"
name: "favoriteColor"
message: "Select your favorite color"
choices:
- "Red"
- "Green"
- "Blue"
actions:
- type: "add"
path: "src/quick-start.json"
template: "quick-start.json"
---

# quick-start.json

```json
{
"name": "{{.name}}",
"favoriteColor": "{{.favoriteColor}}"
}
```

0 comments on commit 7f045f9

Please sign in to comment.