Skip to content

Commit 63eb5d4

Browse files
committed
docs: add README
1 parent 5b5267e commit 63eb5d4

File tree

4 files changed

+129
-9
lines changed

4 files changed

+129
-9
lines changed

README.md

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# gcode-thumbnail-tool
2+
3+
A small tool to analyse and extract thumbnails rendered into GCODE files.
4+
5+
## Installation
6+
7+
```
8+
pip install gcode-thumbnail-tool
9+
```
10+
11+
## Usage
12+
13+
### As a Python library
14+
15+
```python
16+
import gcode_thumbnail_tool as gtt
17+
18+
path = "/path/to/a/file.gcode"
19+
thumbnails = gtt.extract_thumbnails_from_gcode_file(path)
20+
21+
if result:
22+
print(
23+
f'Found {len(result.images)} thumbnails in {args.path}, in format "{result.extractor}":'
24+
)
25+
for image in result.images:
26+
print(f"\t{image.format} @ {image.width}x{image.height}")
27+
else:
28+
print(f"Didn't find any thumbnails in {args.path}")
29+
```
30+
31+
See `gcode_thumbnail_tool.py:main` and `tests/test_api.py` for more usage examples.
32+
33+
### As a command line tool
34+
35+
<!--INSERT:help-->
36+
37+
```
38+
usage: gcode-thumbnail-tool [-h] [--verbose] {extract,analyse} ...
39+
40+
A small CLI tool to extract thumbnail images from GCODE files.
41+
42+
positional arguments:
43+
{extract,analyse}
44+
extract extracts thumbnails from the provided file as PNGs
45+
analyse provides information on the GCODE file's thumbnails
46+
47+
options:
48+
-h, --help show this help message and exit
49+
--verbose, -v increase logging verbosity
50+
```
51+
52+
<!--/INSERT:help-->
53+
54+
#### `extract`
55+
56+
<!--INSERT:extract-->
57+
58+
```
59+
usage: gcode-thumbnail-tool extract [-h] [-o OUTPUT] path
60+
61+
positional arguments:
62+
path path to the GCODE file
63+
64+
options:
65+
-h, --help show this help message and exit
66+
-o OUTPUT, --output OUTPUT
67+
output path for the extracted thumbnails
68+
```
69+
70+
<!--/INSERT:extract-->
71+
72+
#### `analyse`
73+
74+
<!--INSERT:analyse-->
75+
76+
```
77+
usage: gcode-thumbnail-tool analyse [-h] path
78+
79+
positional arguments:
80+
path path to the GCODE file
81+
82+
options:
83+
-h, --help show this help message and exit
84+
```
85+
86+
<!--/INSERT:analyse-->

Taskfile.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
version: "3"
2+
3+
tasks:
4+
update-readme:
5+
cmds:
6+
- |
7+
help_output=$(gcode-thumbnail-tool)
8+
extract_output=$(gcode-thumbnail-tool extract --help)
9+
analyse_output=$(gcode-thumbnail-tool analyse --help)
10+
11+
awk -i inplace -v text="$help_output" '
12+
BEGIN{p=1}
13+
$1=="<!--INSERT:help-->"{p=0;print;next}
14+
$1=="<!--/INSERT:help-->"{print "```\n" text "\n```"; p=1}
15+
p
16+
' README.md
17+
awk -i inplace -v text="$extract_output" '
18+
BEGIN{p=1}
19+
$1=="<!--INSERT:extract-->"{p=0;print;next}
20+
$1=="<!--/INSERT:extract-->"{print "```\n" text "\n```"; p=1}
21+
p
22+
' README.md
23+
awk -i inplace -v text="$analyse_output" '
24+
BEGIN{p=1}
25+
$1=="<!--INSERT:analyse-->"{p=0;print;next}
26+
$1=="<!--/INSERT:analyse-->"{print "```\n" text "\n```"; p=1}
27+
p
28+
' README.md

gcode_thumbnail_tool.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -504,23 +504,29 @@ def main():
504504

505505
parser = argparse.ArgumentParser(
506506
prog="gcode-thumbnail-tool",
507-
description="A small CLI tool to extract thumbnail images from GCODE files",
507+
description="A small CLI tool to extract thumbnail images from GCODE files.",
508+
)
509+
parser.add_argument(
510+
"--verbose",
511+
"-v",
512+
dest="verbosity",
513+
action="count",
514+
help="increase logging verbosity",
508515
)
509-
parser.add_argument("--verbose", "-v", dest="verbosity", action="count")
510516
subparsers = parser.add_subparsers(dest="subcommand")
511517

512518
extract_parser = subparsers.add_parser(
513-
"extract", help="Extracts thumbnails from the provided file as PNGs"
519+
"extract", help="extracts thumbnails from the provided file as PNGs"
514520
)
515-
extract_parser.add_argument("path", help="Path to the GCODE file")
521+
extract_parser.add_argument("path", help="path to the GCODE file")
516522
extract_parser.add_argument(
517-
"-o", "--output", dest="output", help="Output path for the extracted thumbnails"
523+
"-o", "--output", dest="output", help="output path for the extracted thumbnails"
518524
)
519525

520526
analyse_parser = subparsers.add_parser(
521-
"analyse", help="Provides information on the GCODE file's thumbnails"
527+
"analyse", help="provides information on the GCODE file's thumbnails"
522528
)
523-
analyse_parser.add_argument("path", help="Path to the GCODE file")
529+
analyse_parser.add_argument("path", help="path to the GCODE file")
524530

525531
args = parser.parse_args()
526532
if not args.subcommand:

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "gcode-thumbnail-tool"
7-
description = "Small tool to analyse and extract thumbnails rendered into GCODE files"
8-
version = "1.0.0"
7+
description = "A small tool to analyse and extract thumbnails rendered into GCODE files"
8+
version = "0.1.0"
99
dependencies = [
1010
"Pillow>=1.11.3",
1111
]

0 commit comments

Comments
 (0)