Skip to content

Commit

Permalink
Merge pull request #9 from carloscasalar/5-add-a-screen-recording-to-…
Browse files Browse the repository at this point in the history
…the-readme-showcasing-the-generate-npc-cli-command

🍿Add a make command to generate the demo gif
  • Loading branch information
carloscasalar authored Nov 9, 2024
2 parents 68eb7c8 + b85c3a2 commit 9380f2f
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.idea
out
.DS_Store
14 changes: 14 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Define the binary name
BINARY_NAME=./out/generate-npc
BINARY_DEMO_NAME=./demo/generate-npc

DEMO_ASSETS=demo/assets

# Define the main package
MAIN_PACKAGE=./cmd/generate-npc
Expand All @@ -21,6 +24,12 @@ install-tools:
build: out
@go build -o $(BINARY_NAME) $(MAIN_PACKAGE)

# Build binary to generate the demo.gif inside the vhs docker container
build-demo: out
env GOOS=linux go build -o $(BINARY_DEMO_NAME) $(MAIN_PACKAGE)
mkdir -p $(DEMO_ASSETS)
cp assets/* $(DEMO_ASSETS)

# Run the Go application
run: build
$(BINARY_NAME) $(filter-out $@,$(MAKECMDGOALS))
Expand All @@ -36,9 +45,14 @@ lint:
# Run all checks
check: lint test

save-demo-gif: build-demo
docker run --rm -v ${PWD}/demo:/vhs ghcr.io/charmbracelet/vhs demo.tape

# Clean up build artifacts
clean:
rm -f $(BINARY_NAME)
rm -f $(BINARY_DEMO_NAME)
rm -rf $(DEMO_ASSETS)

# Default target
all: build
Expand Down
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,21 @@ According to the previous experience of the NPC, the generator will assign a num
<tr> <td>Elite</td> <td>1</td> <td>2</td> <td>3</td> <td>6</td> </tr>
</tbody>
</table>

## Build & Run

To build the project execute the following command:

```bash
make build
```

This will generate this binary `out/generate-npc`.

To run the project execute the following command:

```bash
./out/generate-npc --help
```

<img src="demo/demo.gif" alt="Demo" />
3 changes: 3 additions & 0 deletions demo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
assets/
*.ascii
generate-npc
7 changes: 7 additions & 0 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Demo

This folder is to generate and store the demo files. To generate the demo gif, go to the repo root directory and type

```bash
make save-demo-gif
```
Binary file added demo/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 18 additions & 0 deletions demo/demo.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Where should we write the GIF?
Output demo.gif

Set FontSize 12
Set Width 900
Set Height 550
Set TypingSpeed 200ms
Set Theme "Catppuccin Frappe"
Set Margin 20
Set BorderRadius 10
Set MarginFill "#6B50FF"
Set WindowBar Colorful

# Type a command in the terminal.
Type "./generate-npc -r pilot"
Show
Enter
Sleep 15s

0 comments on commit 9380f2f

Please sign in to comment.