[PATCH v3 13/14] scripts/ghes_inject: print help if no command specified

Mauro Carvalho Chehab posted 14 patches 1 month, 2 weeks ago
Maintainers: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>, John Snow <jsnow@redhat.com>, Cleber Rosa <crosa@redhat.com>
[PATCH v3 13/14] scripts/ghes_inject: print help if no command specified
Posted by Mauro Carvalho Chehab 1 month, 2 weeks ago
The first positional argument (command) is mandatory. If not
specified, instead of a simple error message, show help as well.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 scripts/ghes_inject.py | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/ghes_inject.py b/scripts/ghes_inject.py
index 781b37cc68af..4028fdb15582 100755
--- a/scripts/ghes_inject.py
+++ b/scripts/ghes_inject.py
@@ -52,6 +52,9 @@ def main():
         if not args.func(args):
             sys.exit(1)
     else:
+        print("Error: no command specified\n", file=sys.stderr)
+        parser.print_help(file=sys.stderr)
+        print(file=sys.stderr)
         sys.exit(f"Please specify a valid command for {sys.argv[0]}")
 
 if __name__ == "__main__":
-- 
2.53.0