From dfec3fb6a9cdfe5f88c8ede156df1cd5b2433598 Mon Sep 17 00:00:00 2001 From: Michael Renzmann Date: Sat, 13 May 2023 01:06:38 +0200 Subject: [PATCH] Improve help text --- examples/v4l2py-ctl.py | 52 ++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 22 deletions(-) diff --git a/examples/v4l2py-ctl.py b/examples/v4l2py-ctl.py index 2b020a1..dc25f34 100644 --- a/examples/v4l2py-ctl.py +++ b/examples/v4l2py-ctl.py @@ -188,60 +188,74 @@ def csv(string: str) -> list: if __name__ == "__main__": - parser = argparse.ArgumentParser() + parser = argparse.ArgumentParser( + prog="v4l2py-ctl", + description="Example utility to control video capture devices.", + epilog="When no action is given, the control status of the selected device is shown.", + ) parser.add_argument( + "--device", + type=str, + default="0", + metavar="", + help="use device instead of /dev/video0; if starts with a digit, then /dev/video is used", + ) + + flags = parser.add_argument_group("Flags") + flags.add_argument( "--legacy", default=False, action="store_true", help="use legacy controls (default: %(default)s)", ) - parser.add_argument( + flags.add_argument( "--clipping", default=False, action="store_true", help="when changing numeric controls, enforce the written value to be within allowed range (default: %(default)s)", ) - parser.add_argument( + flags.add_argument( + "--pedantic", + default=False, + action="store_true", + help="be pedantic when validating a loaded configuration (default: %(default)s)" + ) + + actions = parser.add_argument_group("Actions") + actions.add_argument( "--list-devices", default=False, action="store_true", help="list all video capture devices", ) - parser.add_argument( - "--device", - type=str, - default="0", - metavar="", - help="use device instead of /dev/video0; if starts with a digit, then /dev/video is used", - ) - parser.add_argument( + actions.add_argument( "--get-ctrl", type=csv, default=[], metavar="[,...]", help="get the values of the specified controls", ) - parser.add_argument( + actions.add_argument( "--set-ctrl", type=csv, default=[], metavar="=[,=...]", help="set the values of the specified controls", ) - parser.add_argument( + actions.add_argument( "--reset-ctrl", type=csv, default=[], metavar="[,...]", help="reset the specified controls to their default values", ) - parser.add_argument( + actions.add_argument( "--reset-all", default=False, action="store_true", help="reset all controls to their default value", ) - parser.add_argument( + actions.add_argument( "--save", type=str, dest="save_file", @@ -249,7 +263,7 @@ def csv(string: str) -> list: metavar="", help="save current configuration to ", ) - parser.add_argument( + actions.add_argument( "--load", type=str, dest="load_file", @@ -257,12 +271,6 @@ def csv(string: str) -> list: metavar="", help="load configuration from and apply it to selected device", ) - parser.add_argument( - "--pedantic", - default=False, - action="store_true", - help="be pedantic when validating a configuration (--load only)" - ) args = parser.parse_args()