tools: parse the argument before starting ratbagd
No point starting ratbagd for things like --help or invalid commands
@@ -41,21 +41,21 @@ def main(argv):
if not argv:
argv = ["list"]
+ cmd = None
+ try:
+ parser = toolbox.get_parser()
+ parser.want_keepalive = True
+ cmd = parser.parse(argv)
+ if cmd.help:
+ parser.print_help()
+ return
+
ratbagd_process = toolbox.start_ratbagd()
if ratbagd_process is None:
sys.exit("Failed to start or connect to ratbagd")
ratbagd = toolbox.open_ratbagd()
- parser = toolbox.get_parser()
- parser.want_keepalive = True
- cmd = None
-
- try:
- cmd = parser.parse(argv)
- if cmd.help:
- parser.print_help()
- else:
try:
f = cmd.func
except AttributeError:
