pklaus / brother_ql

Python package for the raster language protocol of the Brother QL series label printers (QL-500, QL-550, QL-560, QL-570, QL-700, QL-710W, QL-720NW, QL-800, QL-810W, QL-820NWB, QL-1050, QL-1060N and more).
GNU General Public License v3.0
562 stars 168 forks source link

Improve error message if label omitted #123

Open MarcelRobitaille opened 2 years ago

MarcelRobitaille commented 2 years ago

The error message when the --label flag is forgotten is cryptic. It is not easy to see what went wrong, or even if it was a bug or your own fault.

Here is what I get:

Traceback (most recent call last):
  File "/home/marcel/code/quin/CNT_Automation/barcoding/venv/bin/brother_ql", line 8, in <module>
    sys.exit(cli())
  File "/home/marcel/code/quin/CNT_Automation/barcoding/venv/lib/python3.10/site-packages/click/core.py", line 1128, in __call__
    return self.main(*args, **kwargs)
  File "/home/marcel/code/quin/CNT_Automation/barcoding/venv/lib/python3.10/site-packages/click/core.py", line 1053, in main
    rv = self.invoke(ctx)
  File "/home/marcel/code/quin/CNT_Automation/barcoding/venv/lib/python3.10/site-packages/click/core.py", line 1659, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/marcel/code/quin/CNT_Automation/barcoding/venv/lib/python3.10/site-packages/click/core.py", line 1395, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/marcel/code/quin/CNT_Automation/barcoding/venv/lib/python3.10/site-packages/click/core.py", line 754, in invoke
    return __callback(*args, **kwargs)
  File "/home/marcel/code/quin/CNT_Automation/barcoding/venv/lib/python3.10/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/marcel/code/quin/CNT_Automation/barcoding/venv/lib/python3.10/site-packages/brother_ql/cli.py", line 146, in print_cmd
    instructions = convert(qlr=qlr, **kwargs)
  File "/home/marcel/code/quin/CNT_Automation/barcoding/venv/lib/python3.10/site-packages/brother_ql/conversion.py", line 48, in convert
    label_specs = label_type_specs[label]
KeyError: None

I would expect something like:

The flag `--label` is required

My command:

venv/bin/brother_ql --printer usb://0x04f9:0x2043 --model QL-710W print  /tmp/qr.png