Add --verbose flag

This commit is contained in:
AndBondStyle
2023-12-06 13:48:24 +03:00
parent 33bf8789ac
commit 2199e65588
3 changed files with 15 additions and 2 deletions
+13 -1
View File
@@ -1,3 +1,4 @@
import logging
import re
import click
@@ -51,7 +52,18 @@ from niimprint import BluetoothTransport, PrinterClient, SerialTransport
required=True,
help="Image path",
)
def print_cmd(model, conn, addr, density, rotate, image):
@click.option(
"-v",
"--verbose",
is_flag=True,
help="Enable verbose logging",
)
def print_cmd(model, conn, addr, density, rotate, image, verbose):
logging.basicConfig(
level="DEBUG" if verbose else "INFO",
format="%(levelname)s | %(module)s:%(funcName)s:%(lineno)d - %(message)s",
)
if conn == "bluetooth":
assert conn is not None, "--addr argument required for bluetooth connection"
addr = addr.upper()
+1 -1
View File
@@ -82,7 +82,7 @@ class SerialTransport(BaseTransport):
if len(all_ports) == 0:
raise RuntimeError("No serial ports detected")
if len(all_ports) > 1:
msg = "Too many serial ports, please select one via SERIAL_PORT env var:"
msg = "Too many serial ports, please select specific one:"
for port, desc, hwid in all_ports:
msg += f"\n- {port} : {desc} [{hwid}]"
raise RuntimeError(msg)
+1
View File
@@ -28,6 +28,7 @@ Options:
-d, --density INTEGER RANGE Print density [default: 5; 1<=x<=5]
-r, --rotate [0|90|180|270] Image rotation (clockwise) [default: 0]
-i, --image PATH Image path [required]
-v, --verbose Enable verbose logging
--help Show this message and exit.
```