paperang-cli 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- paperang_cli-0.1.0/LICENSE +23 -0
- paperang_cli-0.1.0/PKG-INFO +258 -0
- paperang_cli-0.1.0/README.md +219 -0
- paperang_cli-0.1.0/pyproject.toml +67 -0
- paperang_cli-0.1.0/setup.cfg +4 -0
- paperang_cli-0.1.0/src/paperang_cli/__init__.py +3 -0
- paperang_cli-0.1.0/src/paperang_cli/__main__.py +5 -0
- paperang_cli-0.1.0/src/paperang_cli/cli.py +82 -0
- paperang_cli-0.1.0/src/paperang_cli/commands/__init__.py +1 -0
- paperang_cli-0.1.0/src/paperang_cli/commands/battery.py +28 -0
- paperang_cli-0.1.0/src/paperang_cli/commands/config_cmd.py +80 -0
- paperang_cli-0.1.0/src/paperang_cli/commands/discover.py +23 -0
- paperang_cli-0.1.0/src/paperang_cli/commands/mac.py +28 -0
- paperang_cli-0.1.0/src/paperang_cli/commands/print_cmd.py +260 -0
- paperang_cli-0.1.0/src/paperang_cli/commands/probe.py +57 -0
- paperang_cli-0.1.0/src/paperang_cli/commands/status.py +33 -0
- paperang_cli-0.1.0/src/paperang_cli/config.py +109 -0
- paperang_cli-0.1.0/src/paperang_cli/drivers/__init__.py +1 -0
- paperang_cli-0.1.0/src/paperang_cli/drivers/base.py +86 -0
- paperang_cli-0.1.0/src/paperang_cli/drivers/paperang_p1.py +383 -0
- paperang_cli-0.1.0/src/paperang_cli/drivers/registry.py +24 -0
- paperang_cli-0.1.0/src/paperang_cli/errors.py +30 -0
- paperang_cli-0.1.0/src/paperang_cli/models.py +101 -0
- paperang_cli-0.1.0/src/paperang_cli/output.py +52 -0
- paperang_cli-0.1.0/src/paperang_cli/protocol/const.py +62 -0
- paperang_cli-0.1.0/src/paperang_cli/protocol/hardware_bleak.py +425 -0
- paperang_cli-0.1.0/src/paperang_cli/protocol/image_data.py +234 -0
- paperang_cli-0.1.0/src/paperang_cli/render.py +207 -0
- paperang_cli-0.1.0/src/paperang_cli.egg-info/PKG-INFO +258 -0
- paperang_cli-0.1.0/src/paperang_cli.egg-info/SOURCES.txt +36 -0
- paperang_cli-0.1.0/src/paperang_cli.egg-info/dependency_links.txt +1 -0
- paperang_cli-0.1.0/src/paperang_cli.egg-info/entry_points.txt +3 -0
- paperang_cli-0.1.0/src/paperang_cli.egg-info/requires.txt +16 -0
- paperang_cli-0.1.0/src/paperang_cli.egg-info/top_level.txt +1 -0
- paperang_cli-0.1.0/tests/test_cli.py +163 -0
- paperang_cli-0.1.0/tests/test_config.py +49 -0
- paperang_cli-0.1.0/tests/test_registry.py +22 -0
- paperang_cli-0.1.0/tests/test_render.py +72 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 ihc童鞋@提不起劲
|
|
4
|
+
Copyright (c) 2019 BroncoTc
|
|
5
|
+
Copyright (c) 2026 wyrtensi
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: paperang-cli
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Standalone CLI for Paperang thermal printers
|
|
5
|
+
Author: wyrtensi
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/wyrtensi/paperang-cli
|
|
8
|
+
Project-URL: Documentation, https://github.com/wyrtensi/paperang-cli/tree/main/docs
|
|
9
|
+
Project-URL: Issues, https://github.com/wyrtensi/paperang-cli/issues
|
|
10
|
+
Project-URL: Source, https://github.com/wyrtensi/paperang-cli
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Topic :: System :: Hardware :: Hardware Drivers
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: bleak>=0.21.1
|
|
25
|
+
Requires-Dist: click>=8.1.7
|
|
26
|
+
Requires-Dist: numpy>=1.26.0
|
|
27
|
+
Requires-Dist: Pillow>=10.0.0
|
|
28
|
+
Requires-Dist: scikit-image>=0.20.0
|
|
29
|
+
Requires-Dist: scipy>=1.11.0
|
|
30
|
+
Requires-Dist: numba>=0.58.0
|
|
31
|
+
Requires-Dist: pilkit>=2.0
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
|
|
35
|
+
Provides-Extra: release
|
|
36
|
+
Requires-Dist: build>=1.2.2; extra == "release"
|
|
37
|
+
Requires-Dist: twine>=6.0.0; extra == "release"
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
|
|
40
|
+
# paperang-cli
|
|
41
|
+
|
|
42
|
+
[](https://github.com/wyrtensi/paperang-cli/actions/workflows/ci.yml)
|
|
43
|
+
[](https://pypi.org/project/paperang-cli/)
|
|
44
|
+
[](https://pypi.org/project/paperang-cli/)
|
|
45
|
+
[](LICENSE)
|
|
46
|
+

|
|
47
|
+
|
|
48
|
+
`paperang-cli` is a standalone command-line tool for working with Paperang thermal printers from Python.
|
|
49
|
+
|
|
50
|
+
It provides a small, script-friendly interface for discovering a printer, checking its status, and printing text or images with explicit safety gates. JSON output is available for automation and agent-driven workflows.
|
|
51
|
+
|
|
52
|
+
## Current Support
|
|
53
|
+
|
|
54
|
+
Version `0.1.0` supports:
|
|
55
|
+
|
|
56
|
+
| Printer | Transport | Status |
|
|
57
|
+
| --- | --- | --- |
|
|
58
|
+
| Paperang P1 | Bluetooth Low Energy (BLE) | Supported |
|
|
59
|
+
|
|
60
|
+
Local, cable, and USB data transports are not supported for Paperang P1 in this package.
|
|
61
|
+
|
|
62
|
+
Real printer communication and physical printing have been tested only on Windows. CI runs compatibility checks on Linux and macOS, but those checks do not prove BLE or printer behavior on those platforms.
|
|
63
|
+
|
|
64
|
+
## Features
|
|
65
|
+
|
|
66
|
+
- Discover nearby Paperang printers over BLE
|
|
67
|
+
- Check battery level, Bluetooth MAC address, and live printer status
|
|
68
|
+
- Print short text or wrapped paragraphs
|
|
69
|
+
- Print local images with sticker and photo conversion presets
|
|
70
|
+
- Compose text and an image into one print job
|
|
71
|
+
- Preview every print path with `--dry-run`
|
|
72
|
+
- Emit machine-readable JSON with `--json`
|
|
73
|
+
- Use explicit allow flags before any paper-consuming operation
|
|
74
|
+
|
|
75
|
+
Image and composed printing are available, but remain experimental until you validate physical output on your printer.
|
|
76
|
+
|
|
77
|
+
## Installation
|
|
78
|
+
|
|
79
|
+
Python `3.10` or newer is required.
|
|
80
|
+
|
|
81
|
+
Install the published package from PyPI:
|
|
82
|
+
|
|
83
|
+
```powershell
|
|
84
|
+
python -m pip install paperang-cli
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
For local development, clone the repository and install it in editable mode:
|
|
88
|
+
|
|
89
|
+
```powershell
|
|
90
|
+
git clone https://github.com/wyrtensi/paperang-cli.git
|
|
91
|
+
Set-Location "paperang-cli"
|
|
92
|
+
python -m pip install -e ".[dev]"
|
|
93
|
+
python -m pytest
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
The package installs two equivalent commands:
|
|
97
|
+
|
|
98
|
+
- `paperang`
|
|
99
|
+
- `paperang-cli`
|
|
100
|
+
|
|
101
|
+
Use `paperang` by default. Use `paperang-cli` if the shorter command conflicts with another executable on your system.
|
|
102
|
+
|
|
103
|
+
## Safe First Run
|
|
104
|
+
|
|
105
|
+
Start with commands that do not consume paper:
|
|
106
|
+
|
|
107
|
+
```powershell
|
|
108
|
+
paperang --json config show
|
|
109
|
+
paperang --json discover
|
|
110
|
+
paperang --json probe
|
|
111
|
+
paperang --json battery
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Before a real print, run the matching command with `--dry-run`:
|
|
115
|
+
|
|
116
|
+
```powershell
|
|
117
|
+
paperang --json print text "Hello from Paperang" --dry-run
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
After checking the result, explicitly allow paper use:
|
|
121
|
+
|
|
122
|
+
```powershell
|
|
123
|
+
paperang --json print text "Hello from Paperang" --allow-paper-use
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Keep the content, image, layout, conversion mode, font size, and feed options the same between dry-run and the real print.
|
|
127
|
+
|
|
128
|
+
## Printing
|
|
129
|
+
|
|
130
|
+
### Text
|
|
131
|
+
|
|
132
|
+
```powershell
|
|
133
|
+
paperang --json print text "Shipping label" --dry-run
|
|
134
|
+
paperang --json print text "Shipping label" --allow-paper-use
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
### Paragraph
|
|
138
|
+
|
|
139
|
+
```powershell
|
|
140
|
+
paperang --json print paragraph "A longer wrapped note for the printer." --dry-run
|
|
141
|
+
paperang --json print paragraph "A longer wrapped note for the printer." --allow-paper-use
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Image
|
|
145
|
+
|
|
146
|
+
Use `--mode sticker` for logos, icons, and line art:
|
|
147
|
+
|
|
148
|
+
```powershell
|
|
149
|
+
paperang --json print image ".\sample.png" --dry-run --mode sticker
|
|
150
|
+
paperang --json print image ".\sample.png" --allow-paper-use --mode sticker
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
Use `--mode photo` as a starting point for photographs and smoother grayscale content:
|
|
154
|
+
|
|
155
|
+
```powershell
|
|
156
|
+
paperang --json print image ".\photo.jpg" --dry-run --mode photo
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
Image quality depends on the source file and printer. A successful dry-run validates conversion and packaging, not the final paper output.
|
|
160
|
+
|
|
161
|
+
### Compose
|
|
162
|
+
|
|
163
|
+
`print compose` combines wrapped text and an image in one vertical layout:
|
|
164
|
+
|
|
165
|
+
```powershell
|
|
166
|
+
paperang --json print compose "Product label" ".\sample.png" --dry-run --mode sticker
|
|
167
|
+
paperang --json print compose "Product label" ".\sample.png" --allow-paper-use --mode sticker
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
Use `--layout image-above` when the image should be printed before the text:
|
|
171
|
+
|
|
172
|
+
```powershell
|
|
173
|
+
paperang --json print compose "Product label" ".\sample.png" --dry-run --layout image-above
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
Compose printing uses the same experimental image conversion pipeline as `print image`.
|
|
177
|
+
|
|
178
|
+
### Built-In Self-Test
|
|
179
|
+
|
|
180
|
+
The printer self-test consumes substantially more paper than an ordinary print. Use it only when you explicitly want the printer's built-in diagnostic page:
|
|
181
|
+
|
|
182
|
+
```powershell
|
|
183
|
+
paperang --json print self-test --dry-run
|
|
184
|
+
paperang --json print self-test --allow-large-paper-use
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
The self-test dry-run only validates the CLI path and warning payload. It does not query hidden hardware state.
|
|
188
|
+
|
|
189
|
+
## Commands
|
|
190
|
+
|
|
191
|
+
| Command | Purpose |
|
|
192
|
+
| --- | --- |
|
|
193
|
+
| `paperang discover` | Scan for nearby supported printers |
|
|
194
|
+
| `paperang battery` | Query the current battery percentage |
|
|
195
|
+
| `paperang mac` | Query the printer-reported Bluetooth MAC address |
|
|
196
|
+
| `paperang status` | Query live printer information |
|
|
197
|
+
| `paperang probe` | Return a combined readiness summary |
|
|
198
|
+
| `paperang print text` | Print a short text block |
|
|
199
|
+
| `paperang print paragraph` | Print wrapped text |
|
|
200
|
+
| `paperang print image` | Print a local image |
|
|
201
|
+
| `paperang print compose` | Print text and an image as one job |
|
|
202
|
+
| `paperang print self-test` | Print the built-in diagnostic page |
|
|
203
|
+
| `paperang config show` | Show the resolved config and active settings |
|
|
204
|
+
| `paperang config path` | Show the resolved config path |
|
|
205
|
+
| `paperang config init` | Write an example config file |
|
|
206
|
+
|
|
207
|
+
Run `paperang --help` or `paperang <command> --help` for the available options.
|
|
208
|
+
|
|
209
|
+
## Configuration
|
|
210
|
+
|
|
211
|
+
Inspect the active config:
|
|
212
|
+
|
|
213
|
+
```powershell
|
|
214
|
+
paperang --json config show
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
Create an example config:
|
|
218
|
+
|
|
219
|
+
```powershell
|
|
220
|
+
paperang config init
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
Configuration is resolved in this order:
|
|
224
|
+
|
|
225
|
+
1. `--config PATH`
|
|
226
|
+
2. `PAPERANG_CLI_CONFIG`
|
|
227
|
+
3. the per-user default config path
|
|
228
|
+
4. built-in defaults
|
|
229
|
+
|
|
230
|
+
Default paths:
|
|
231
|
+
|
|
232
|
+
- Windows: `%APPDATA%\paperang-cli\paperang-cli.config.json`
|
|
233
|
+
- Linux and macOS: `$XDG_CONFIG_HOME/paperang-cli/paperang-cli.config.json`, or `~/.config/paperang-cli/paperang-cli.config.json`
|
|
234
|
+
|
|
235
|
+
See [Configuration](docs/usage/configuration.md) for the full schema.
|
|
236
|
+
|
|
237
|
+
## Documentation
|
|
238
|
+
|
|
239
|
+
- [Documentation index](docs/index.md)
|
|
240
|
+
- [Installation guide](docs/installation.md)
|
|
241
|
+
- [Command reference](docs/usage/commands.md)
|
|
242
|
+
- [Configuration](docs/usage/configuration.md)
|
|
243
|
+
- [Troubleshooting](docs/troubleshooting.md)
|
|
244
|
+
- [Agent contract](docs/agents/cli-contract.md)
|
|
245
|
+
- [Publishing runbook for agents](docs/agents/publishing.md)
|
|
246
|
+
|
|
247
|
+
## Project History And Acknowledgements
|
|
248
|
+
|
|
249
|
+
This standalone CLI builds on earlier reverse engineering and Paperang P1 control work by:
|
|
250
|
+
|
|
251
|
+
- `ihc童鞋@提不起劲`
|
|
252
|
+
- `BroncoTc`
|
|
253
|
+
|
|
254
|
+
The current `paperang-cli` package is maintained by `wyrtensi`.
|
|
255
|
+
|
|
256
|
+
## License
|
|
257
|
+
|
|
258
|
+
This package is available under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# paperang-cli
|
|
2
|
+
|
|
3
|
+
[](https://github.com/wyrtensi/paperang-cli/actions/workflows/ci.yml)
|
|
4
|
+
[](https://pypi.org/project/paperang-cli/)
|
|
5
|
+
[](https://pypi.org/project/paperang-cli/)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+

|
|
8
|
+
|
|
9
|
+
`paperang-cli` is a standalone command-line tool for working with Paperang thermal printers from Python.
|
|
10
|
+
|
|
11
|
+
It provides a small, script-friendly interface for discovering a printer, checking its status, and printing text or images with explicit safety gates. JSON output is available for automation and agent-driven workflows.
|
|
12
|
+
|
|
13
|
+
## Current Support
|
|
14
|
+
|
|
15
|
+
Version `0.1.0` supports:
|
|
16
|
+
|
|
17
|
+
| Printer | Transport | Status |
|
|
18
|
+
| --- | --- | --- |
|
|
19
|
+
| Paperang P1 | Bluetooth Low Energy (BLE) | Supported |
|
|
20
|
+
|
|
21
|
+
Local, cable, and USB data transports are not supported for Paperang P1 in this package.
|
|
22
|
+
|
|
23
|
+
Real printer communication and physical printing have been tested only on Windows. CI runs compatibility checks on Linux and macOS, but those checks do not prove BLE or printer behavior on those platforms.
|
|
24
|
+
|
|
25
|
+
## Features
|
|
26
|
+
|
|
27
|
+
- Discover nearby Paperang printers over BLE
|
|
28
|
+
- Check battery level, Bluetooth MAC address, and live printer status
|
|
29
|
+
- Print short text or wrapped paragraphs
|
|
30
|
+
- Print local images with sticker and photo conversion presets
|
|
31
|
+
- Compose text and an image into one print job
|
|
32
|
+
- Preview every print path with `--dry-run`
|
|
33
|
+
- Emit machine-readable JSON with `--json`
|
|
34
|
+
- Use explicit allow flags before any paper-consuming operation
|
|
35
|
+
|
|
36
|
+
Image and composed printing are available, but remain experimental until you validate physical output on your printer.
|
|
37
|
+
|
|
38
|
+
## Installation
|
|
39
|
+
|
|
40
|
+
Python `3.10` or newer is required.
|
|
41
|
+
|
|
42
|
+
Install the published package from PyPI:
|
|
43
|
+
|
|
44
|
+
```powershell
|
|
45
|
+
python -m pip install paperang-cli
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
For local development, clone the repository and install it in editable mode:
|
|
49
|
+
|
|
50
|
+
```powershell
|
|
51
|
+
git clone https://github.com/wyrtensi/paperang-cli.git
|
|
52
|
+
Set-Location "paperang-cli"
|
|
53
|
+
python -m pip install -e ".[dev]"
|
|
54
|
+
python -m pytest
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The package installs two equivalent commands:
|
|
58
|
+
|
|
59
|
+
- `paperang`
|
|
60
|
+
- `paperang-cli`
|
|
61
|
+
|
|
62
|
+
Use `paperang` by default. Use `paperang-cli` if the shorter command conflicts with another executable on your system.
|
|
63
|
+
|
|
64
|
+
## Safe First Run
|
|
65
|
+
|
|
66
|
+
Start with commands that do not consume paper:
|
|
67
|
+
|
|
68
|
+
```powershell
|
|
69
|
+
paperang --json config show
|
|
70
|
+
paperang --json discover
|
|
71
|
+
paperang --json probe
|
|
72
|
+
paperang --json battery
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Before a real print, run the matching command with `--dry-run`:
|
|
76
|
+
|
|
77
|
+
```powershell
|
|
78
|
+
paperang --json print text "Hello from Paperang" --dry-run
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
After checking the result, explicitly allow paper use:
|
|
82
|
+
|
|
83
|
+
```powershell
|
|
84
|
+
paperang --json print text "Hello from Paperang" --allow-paper-use
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
Keep the content, image, layout, conversion mode, font size, and feed options the same between dry-run and the real print.
|
|
88
|
+
|
|
89
|
+
## Printing
|
|
90
|
+
|
|
91
|
+
### Text
|
|
92
|
+
|
|
93
|
+
```powershell
|
|
94
|
+
paperang --json print text "Shipping label" --dry-run
|
|
95
|
+
paperang --json print text "Shipping label" --allow-paper-use
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Paragraph
|
|
99
|
+
|
|
100
|
+
```powershell
|
|
101
|
+
paperang --json print paragraph "A longer wrapped note for the printer." --dry-run
|
|
102
|
+
paperang --json print paragraph "A longer wrapped note for the printer." --allow-paper-use
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Image
|
|
106
|
+
|
|
107
|
+
Use `--mode sticker` for logos, icons, and line art:
|
|
108
|
+
|
|
109
|
+
```powershell
|
|
110
|
+
paperang --json print image ".\sample.png" --dry-run --mode sticker
|
|
111
|
+
paperang --json print image ".\sample.png" --allow-paper-use --mode sticker
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Use `--mode photo` as a starting point for photographs and smoother grayscale content:
|
|
115
|
+
|
|
116
|
+
```powershell
|
|
117
|
+
paperang --json print image ".\photo.jpg" --dry-run --mode photo
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Image quality depends on the source file and printer. A successful dry-run validates conversion and packaging, not the final paper output.
|
|
121
|
+
|
|
122
|
+
### Compose
|
|
123
|
+
|
|
124
|
+
`print compose` combines wrapped text and an image in one vertical layout:
|
|
125
|
+
|
|
126
|
+
```powershell
|
|
127
|
+
paperang --json print compose "Product label" ".\sample.png" --dry-run --mode sticker
|
|
128
|
+
paperang --json print compose "Product label" ".\sample.png" --allow-paper-use --mode sticker
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Use `--layout image-above` when the image should be printed before the text:
|
|
132
|
+
|
|
133
|
+
```powershell
|
|
134
|
+
paperang --json print compose "Product label" ".\sample.png" --dry-run --layout image-above
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Compose printing uses the same experimental image conversion pipeline as `print image`.
|
|
138
|
+
|
|
139
|
+
### Built-In Self-Test
|
|
140
|
+
|
|
141
|
+
The printer self-test consumes substantially more paper than an ordinary print. Use it only when you explicitly want the printer's built-in diagnostic page:
|
|
142
|
+
|
|
143
|
+
```powershell
|
|
144
|
+
paperang --json print self-test --dry-run
|
|
145
|
+
paperang --json print self-test --allow-large-paper-use
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
The self-test dry-run only validates the CLI path and warning payload. It does not query hidden hardware state.
|
|
149
|
+
|
|
150
|
+
## Commands
|
|
151
|
+
|
|
152
|
+
| Command | Purpose |
|
|
153
|
+
| --- | --- |
|
|
154
|
+
| `paperang discover` | Scan for nearby supported printers |
|
|
155
|
+
| `paperang battery` | Query the current battery percentage |
|
|
156
|
+
| `paperang mac` | Query the printer-reported Bluetooth MAC address |
|
|
157
|
+
| `paperang status` | Query live printer information |
|
|
158
|
+
| `paperang probe` | Return a combined readiness summary |
|
|
159
|
+
| `paperang print text` | Print a short text block |
|
|
160
|
+
| `paperang print paragraph` | Print wrapped text |
|
|
161
|
+
| `paperang print image` | Print a local image |
|
|
162
|
+
| `paperang print compose` | Print text and an image as one job |
|
|
163
|
+
| `paperang print self-test` | Print the built-in diagnostic page |
|
|
164
|
+
| `paperang config show` | Show the resolved config and active settings |
|
|
165
|
+
| `paperang config path` | Show the resolved config path |
|
|
166
|
+
| `paperang config init` | Write an example config file |
|
|
167
|
+
|
|
168
|
+
Run `paperang --help` or `paperang <command> --help` for the available options.
|
|
169
|
+
|
|
170
|
+
## Configuration
|
|
171
|
+
|
|
172
|
+
Inspect the active config:
|
|
173
|
+
|
|
174
|
+
```powershell
|
|
175
|
+
paperang --json config show
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
Create an example config:
|
|
179
|
+
|
|
180
|
+
```powershell
|
|
181
|
+
paperang config init
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Configuration is resolved in this order:
|
|
185
|
+
|
|
186
|
+
1. `--config PATH`
|
|
187
|
+
2. `PAPERANG_CLI_CONFIG`
|
|
188
|
+
3. the per-user default config path
|
|
189
|
+
4. built-in defaults
|
|
190
|
+
|
|
191
|
+
Default paths:
|
|
192
|
+
|
|
193
|
+
- Windows: `%APPDATA%\paperang-cli\paperang-cli.config.json`
|
|
194
|
+
- Linux and macOS: `$XDG_CONFIG_HOME/paperang-cli/paperang-cli.config.json`, or `~/.config/paperang-cli/paperang-cli.config.json`
|
|
195
|
+
|
|
196
|
+
See [Configuration](docs/usage/configuration.md) for the full schema.
|
|
197
|
+
|
|
198
|
+
## Documentation
|
|
199
|
+
|
|
200
|
+
- [Documentation index](docs/index.md)
|
|
201
|
+
- [Installation guide](docs/installation.md)
|
|
202
|
+
- [Command reference](docs/usage/commands.md)
|
|
203
|
+
- [Configuration](docs/usage/configuration.md)
|
|
204
|
+
- [Troubleshooting](docs/troubleshooting.md)
|
|
205
|
+
- [Agent contract](docs/agents/cli-contract.md)
|
|
206
|
+
- [Publishing runbook for agents](docs/agents/publishing.md)
|
|
207
|
+
|
|
208
|
+
## Project History And Acknowledgements
|
|
209
|
+
|
|
210
|
+
This standalone CLI builds on earlier reverse engineering and Paperang P1 control work by:
|
|
211
|
+
|
|
212
|
+
- `ihc童鞋@提不起劲`
|
|
213
|
+
- `BroncoTc`
|
|
214
|
+
|
|
215
|
+
The current `paperang-cli` package is maintained by `wyrtensi`.
|
|
216
|
+
|
|
217
|
+
## License
|
|
218
|
+
|
|
219
|
+
This package is available under the [MIT License](LICENSE).
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "paperang-cli"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Standalone CLI for Paperang thermal printers"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{ name = "wyrtensi" },
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 3 - Alpha",
|
|
18
|
+
"Environment :: Console",
|
|
19
|
+
"Operating System :: Microsoft :: Windows",
|
|
20
|
+
"Programming Language :: Python :: 3",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Programming Language :: Python :: 3.14",
|
|
26
|
+
"Topic :: System :: Hardware :: Hardware Drivers",
|
|
27
|
+
]
|
|
28
|
+
dependencies = [
|
|
29
|
+
"bleak>=0.21.1",
|
|
30
|
+
"click>=8.1.7",
|
|
31
|
+
"numpy>=1.26.0",
|
|
32
|
+
"Pillow>=10.0.0",
|
|
33
|
+
"scikit-image>=0.20.0",
|
|
34
|
+
"scipy>=1.11.0",
|
|
35
|
+
"numba>=0.58.0",
|
|
36
|
+
"pilkit>=2.0",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.optional-dependencies]
|
|
40
|
+
dev = [
|
|
41
|
+
"pytest>=8.0.0",
|
|
42
|
+
"pytest-cov>=5.0.0",
|
|
43
|
+
]
|
|
44
|
+
release = [
|
|
45
|
+
"build>=1.2.2",
|
|
46
|
+
"twine>=6.0.0",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[project.urls]
|
|
50
|
+
Homepage = "https://github.com/wyrtensi/paperang-cli"
|
|
51
|
+
Documentation = "https://github.com/wyrtensi/paperang-cli/tree/main/docs"
|
|
52
|
+
Issues = "https://github.com/wyrtensi/paperang-cli/issues"
|
|
53
|
+
Source = "https://github.com/wyrtensi/paperang-cli"
|
|
54
|
+
|
|
55
|
+
[project.scripts]
|
|
56
|
+
paperang = "paperang_cli.cli:main"
|
|
57
|
+
paperang-cli = "paperang_cli.cli:main"
|
|
58
|
+
|
|
59
|
+
[tool.pytest.ini_options]
|
|
60
|
+
testpaths = ["tests"]
|
|
61
|
+
addopts = "-q"
|
|
62
|
+
|
|
63
|
+
[tool.setuptools.package-dir]
|
|
64
|
+
"" = "src"
|
|
65
|
+
|
|
66
|
+
[tool.setuptools.packages.find]
|
|
67
|
+
where = ["src"]
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""Standalone paperang-cli entrypoint."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
import logging
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
|
|
9
|
+
import click
|
|
10
|
+
|
|
11
|
+
from paperang_cli import __version__
|
|
12
|
+
from paperang_cli.commands.battery import battery_command
|
|
13
|
+
from paperang_cli.commands.config_cmd import config_group
|
|
14
|
+
from paperang_cli.commands.discover import discover_command
|
|
15
|
+
from paperang_cli.commands.mac import mac_command
|
|
16
|
+
from paperang_cli.commands.print_cmd import print_group
|
|
17
|
+
from paperang_cli.commands.probe import probe_command
|
|
18
|
+
from paperang_cli.commands.status import status_command
|
|
19
|
+
from paperang_cli.config import load_config
|
|
20
|
+
from paperang_cli.errors import PaperangCliError
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def configure_logging(debug: bool) -> None:
|
|
24
|
+
level = logging.DEBUG if debug else logging.INFO
|
|
25
|
+
logging.basicConfig(level=level, format="%(asctime)s %(levelname)s %(name)s: %(message)s")
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@click.group(context_settings={"help_option_names": ["-h", "--help"]})
|
|
29
|
+
@click.option(
|
|
30
|
+
"--config",
|
|
31
|
+
"config_path",
|
|
32
|
+
type=click.Path(path_type=Path, dir_okay=False),
|
|
33
|
+
help="Path to a paperang-cli JSON config file.",
|
|
34
|
+
)
|
|
35
|
+
@click.option("--json", "json_output", is_flag=True, help="Emit machine-readable JSON output.")
|
|
36
|
+
@click.option("--debug", is_flag=True, help="Enable verbose logging.")
|
|
37
|
+
@click.version_option(version=__version__)
|
|
38
|
+
@click.pass_context
|
|
39
|
+
def cli(ctx: click.Context, config_path: Path | None, json_output: bool, debug: bool) -> None:
|
|
40
|
+
"""Standalone CLI for Paperang printers."""
|
|
41
|
+
configure_logging(debug)
|
|
42
|
+
try:
|
|
43
|
+
settings, resolved_path, config_exists = load_config(config_path)
|
|
44
|
+
except PaperangCliError as exc:
|
|
45
|
+
if json_output:
|
|
46
|
+
click.echo(
|
|
47
|
+
json.dumps(
|
|
48
|
+
{
|
|
49
|
+
"status": "error",
|
|
50
|
+
"code": exc.code,
|
|
51
|
+
"message": str(exc),
|
|
52
|
+
"exit_code": exc.exit_code,
|
|
53
|
+
},
|
|
54
|
+
indent=2,
|
|
55
|
+
ensure_ascii=False,
|
|
56
|
+
sort_keys=True,
|
|
57
|
+
),
|
|
58
|
+
err=True,
|
|
59
|
+
)
|
|
60
|
+
raise SystemExit(exc.exit_code)
|
|
61
|
+
raise click.ClickException(str(exc)) from exc
|
|
62
|
+
|
|
63
|
+
ctx.obj = {
|
|
64
|
+
"settings": settings,
|
|
65
|
+
"config_path": resolved_path,
|
|
66
|
+
"config_exists": config_exists,
|
|
67
|
+
"json_output": json_output,
|
|
68
|
+
"debug": debug,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
cli.add_command(status_command)
|
|
73
|
+
cli.add_command(battery_command)
|
|
74
|
+
cli.add_command(mac_command)
|
|
75
|
+
cli.add_command(probe_command)
|
|
76
|
+
cli.add_command(discover_command)
|
|
77
|
+
cli.add_command(print_group)
|
|
78
|
+
cli.add_command(config_group)
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def main() -> None:
|
|
82
|
+
cli()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""CLI commands."""
|