JamesHarrison / openob

The Open Outside Broadcast project for radio contribution links and studio-transmitter links.
158 stars 34 forks source link

patch: Show help for rx and tx mode #35

Open whohoho opened 6 years ago

whohoho commented 6 years ago

Openob does not show the help for the cli options for rx and tx mode.

Here is a patch:

https://github.com/whohoho/openob/commit/ef613ef3d94ef0ebfef377aa4b538753378f71ef

diff --git a/bin/openob b/bin/openob
index 64ee4c2..4ce9b44 100755
--- a/bin/openob
+++ b/bin/openob
@@ -9,8 +9,27 @@ from openob.node import Node
 from openob.link_config import LinkConfig
 from openob.audio_interface import AudioInterface

-parser = argparse.ArgumentParser(prog='openob', formatter_class=argparse.ArgumentDefaultsHelpFormatter)
+class _HelpAction(argparse._HelpAction):
+
+    def __call__(self, parser, namespace, values, option_string=None):
+        parser.print_help()
+
+        subparsers_actions = [
+            action for action in parser._actions
+            if isinstance(action, argparse._SubParsersAction)]
+        for subparsers_action in subparsers_actions:
+            for choice, subparser in subparsers_action.choices.items():
+                print("Subparser '{}'".format(choice))
+                print(subparser.format_help())
+
+        parser.exit()
+
+
+parser = argparse.ArgumentParser(prog='openob', formatter_class=argparse.ArgumentDefaultsHelpFormatter, add_help=False)
+
 parser.add_argument('-v', '--verbose', action='store_const', help='Increase logging verbosity', const=logging.DEBUG, default=logging.INFO)
+parser.add_argument('-h', '--help', action=_HelpAction, help='Show help') 
+
 parser.add_argument('config_host', type=str, help="The configuration server for this OpenOB Node")
 parser.add_argument('node_name', type=str, help="The node name for this end")
 parser.add_argument('link_name', type=str, help="The link name this OpenOB Manager is operating on; must be the same on both Nodes")
@@ -51,8 +70,8 @@ parser_rx_jack.add_argument('-jn', '--jack_name', type=str, default='openob', he
 parser_rx_jack.add_argument('-aj', '--jack_auto', action='store_false', help="Disable auto connection for JACK inputs")
 parser_rx.set_defaults(mode='rx')

-opts = parser.parse_args()

+opts = parser.parse_args()
 logger_factory = LoggerFactory(level=opts.verbose)

 link_config = LinkConfig(opts.link_name, opts.config_host)

whohoho commented 6 years ago

And a pull request: https://github.com/JamesHarrison/openob/pull/37

paddatrapper commented 4 years ago

37 has been merged, so this has been solved?