Add --verbose flag
This commit is contained in:
+13
-1
@@ -1,3 +1,4 @@
|
|||||||
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import click
|
import click
|
||||||
@@ -51,7 +52,18 @@ from niimprint import BluetoothTransport, PrinterClient, SerialTransport
|
|||||||
required=True,
|
required=True,
|
||||||
help="Image path",
|
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":
|
if conn == "bluetooth":
|
||||||
assert conn is not None, "--addr argument required for bluetooth connection"
|
assert conn is not None, "--addr argument required for bluetooth connection"
|
||||||
addr = addr.upper()
|
addr = addr.upper()
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class SerialTransport(BaseTransport):
|
|||||||
if len(all_ports) == 0:
|
if len(all_ports) == 0:
|
||||||
raise RuntimeError("No serial ports detected")
|
raise RuntimeError("No serial ports detected")
|
||||||
if len(all_ports) > 1:
|
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:
|
for port, desc, hwid in all_ports:
|
||||||
msg += f"\n- {port} : {desc} [{hwid}]"
|
msg += f"\n- {port} : {desc} [{hwid}]"
|
||||||
raise RuntimeError(msg)
|
raise RuntimeError(msg)
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ Options:
|
|||||||
-d, --density INTEGER RANGE Print density [default: 5; 1<=x<=5]
|
-d, --density INTEGER RANGE Print density [default: 5; 1<=x<=5]
|
||||||
-r, --rotate [0|90|180|270] Image rotation (clockwise) [default: 0]
|
-r, --rotate [0|90|180|270] Image rotation (clockwise) [default: 0]
|
||||||
-i, --image PATH Image path [required]
|
-i, --image PATH Image path [required]
|
||||||
|
-v, --verbose Enable verbose logging
|
||||||
--help Show this message and exit.
|
--help Show this message and exit.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user