Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patch: Show help for rx and tx mode #35

Open
whohoho opened this issue Jul 26, 2018 · 2 comments
Open

patch: Show help for rx and tx mode #35

whohoho opened this issue Jul 26, 2018 · 2 comments

Comments

@whohoho
Copy link

whohoho commented Jul 26, 2018

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

Here is a patch:

whohoho@ef613ef

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 whohoho changed the title Show help for rx and tx mode patch: Show help for rx and tx mode Jul 31, 2018
@whohoho
Copy link
Author

whohoho commented Aug 19, 2018

And a pull request: #37

@paddatrapper
Copy link

#37 has been merged, so this has been solved?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants