Skip to content

Commit a9446d5

Browse files
committed
docs: add CLI example to README
1 parent 9097c6d commit a9446d5

File tree

2 files changed

+42
-9
lines changed

2 files changed

+42
-9
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ See `gcode_thumbnail_tool.py:main` and `tests/test_api.py` for more usage exampl
3535
<!--INSERT:help-->
3636

3737
```
38+
$ gcode-thumbnail-tool
3839
usage: gcode-thumbnail-tool [-h] [--verbose] {extract,analyse} ...
3940
4041
A small CLI tool to extract thumbnail images from GCODE files.
@@ -56,6 +57,7 @@ options:
5657
<!--INSERT:extract-->
5758

5859
```
60+
$ gcode-thumbnail-tool extract --help
5961
usage: gcode-thumbnail-tool extract [-h] [-o OUTPUT] path
6062
6163
positional arguments:
@@ -74,6 +76,7 @@ options:
7476
<!--INSERT:analyse-->
7577

7678
```
79+
$ gcode-thumbnail-tool analyse --help
7780
usage: gcode-thumbnail-tool analyse [-h] path
7881
7982
positional arguments:
@@ -85,6 +88,21 @@ options:
8588

8689
<!--/INSERT:analyse-->
8790

91+
#### Example
92+
93+
<!--INSERT:example-->
94+
95+
```
96+
$ gcode-thumbnail-tool analyse tests/_files/prusa_2.9.3.gcode
97+
Found 4 thumbnails in tests/_files/prusa_2.9.3.gcode, in format "generic":
98+
PNG @ 16x16
99+
PNG @ 220x124
100+
QOI @ 64x64
101+
JPEG @ 64x64
102+
```
103+
104+
<!--/INSERT:example-->
105+
88106
## Acknowledgements
89107

90108
`gcode-thumbnail-tool` is based on the [Slicer Thumbnails OctoPrint Plugin](https://github.com/jneilliii/OctoPrint-PrusaSlicerThumbnails) by jneilliii.

Taskfile.yml

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,40 @@ tasks:
44
update-readme:
55
cmds:
66
- |
7-
help_output=$(gcode-thumbnail-tool)
8-
extract_output=$(gcode-thumbnail-tool extract --help)
9-
analyse_output=$(gcode-thumbnail-tool analyse --help)
7+
help_command="gcode-thumbnail-tool"
8+
help_output=$($help_command)
109
11-
awk -i inplace -v text="$help_output" '
10+
extract_command="gcode-thumbnail-tool extract --help"
11+
extract_output=$($extract_command)
12+
13+
analyse_command="gcode-thumbnail-tool analyse --help"
14+
analyse_output=$($analyse_command)
15+
16+
example_command="gcode-thumbnail-tool analyse tests/_files/prusa_2.9.3.gcode"
17+
example_output=$($example_command)
18+
19+
awk -i inplace -v command="$help_command" -v output="$help_output" '
1220
BEGIN{p=1}
1321
$1=="<!--INSERT:help-->"{p=0;print;next}
14-
$1=="<!--/INSERT:help-->"{print "```\n" text "\n```"; p=1}
22+
$1=="<!--/INSERT:help-->"{print "```\n$ " command "\n" output "\n```"; p=1}
1523
p
1624
' README.md
17-
awk -i inplace -v text="$extract_output" '
25+
awk -i inplace -v command="$extract_command" -v output="$extract_output" '
1826
BEGIN{p=1}
1927
$1=="<!--INSERT:extract-->"{p=0;print;next}
20-
$1=="<!--/INSERT:extract-->"{print "```\n" text "\n```"; p=1}
28+
$1=="<!--/INSERT:extract-->"{print "```\n$ " command "\n" output "\n```"; p=1}
2129
p
2230
' README.md
23-
awk -i inplace -v text="$analyse_output" '
31+
awk -i inplace -v command="$analyse_command" -v output="$analyse_output" '
2432
BEGIN{p=1}
2533
$1=="<!--INSERT:analyse-->"{p=0;print;next}
26-
$1=="<!--/INSERT:analyse-->"{print "```\n" text "\n```"; p=1}
34+
$1=="<!--/INSERT:analyse-->"{print "```\n$ " command "\n" output "\n```"; p=1}
35+
p
36+
' README.md
37+
38+
awk -i inplace -v command="$example_command" -v output="$example_output" '
39+
BEGIN{p=1}
40+
$1=="<!--INSERT:example-->"{p=0;print;next}
41+
$1=="<!--/INSERT:example-->"{print "```\n$ " command "\n" output "\n```"; p=1}
2742
p
2843
' README.md

0 commit comments

Comments
 (0)