luxonis / depthai-python

DepthAI Python Library
MIT License
353 stars 192 forks source link

Make cam_test.py available through the depthai binary. #983

Closed zrezke closed 7 months ago

moratom commented 7 months ago

Very nice, thanks @zrezke!

One nitpick, not directly related to this PR, but the one before for the default cam_test: args, _unknown = parser.parse_known_args() on line 129 in cam_test.py doesn't catch user errors if there's a typo or if non existing options are specified, etc.

Is that needed, or can we parse the arguments there normally?

Not ideal for the cli as well as depthai --invalid_test doesn't point out that this is not a valid option, but I see why it's needed with the current approach.

moratom commented 7 months ago

@zrezke I've pushed a commit that address the debug prints & changes a bit how arg-parse is handled, so all (more?) typos, invalid commands are caught by it.

Please check if you agree with the changes, then we can merge!

zrezke commented 7 months ago

@moratom Thanks for the cleanups, as discussed in person - I modified the "command" approach a little bit, to add seperate commands for each subprogram we will include in the depthai binary (it makes --help nicer).

Help now:

filip@filip:~/Documents/depthai-python$  python3 depthai_cli/depthai_cli.py -h
usage: depthai_cli.py [-h] [-v] [-l] {cam_test} ...

DepthAI CLI

positional arguments:
  {cam_test}          Sub-commands
    cam_test          Commands and options for cam_test

options:
  -h, --help          show this help message and exit
  -v, --version       Print version and exit.
  -l, --list-devices  List connected devices.