aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPrathamesh <yashlohakare48@outlook.com>2022-07-13 22:18:32 +0530
committerNirbheek Chauhan <nirbheek@centricular.com>2022-08-08 19:10:00 +0530
commitc6cd781c76e8cbf981e25ebf44cca483157ab477 (patch)
tree526051185aea5d211978c7bbd68fc124c3c71f90
parent7c6f0256b359025a946be3e3411fdf6c2f58fe2b (diff)
downloadmeson-c6cd781c76e8cbf981e25ebf44cca483157ab477.zip
meson-c6cd781c76e8cbf981e25ebf44cca483157ab477.tar.gz
meson-c6cd781c76e8cbf981e25ebf44cca483157ab477.tar.bz2
Resolve KeyError while executing help command with unknown param
-rw-r--r--mesonbuild/mesonmain.py7
1 files changed, 4 insertions, 3 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py
index 4ca4a96..7589b6c 100644
--- a/mesonbuild/mesonmain.py
+++ b/mesonbuild/mesonmain.py
@@ -61,8 +61,6 @@ class CommandLineParser:
help_msg='Wrap tools')
self.add_command('subprojects', msubprojects.add_arguments, msubprojects.run,
help_msg='Manage subprojects')
- self.add_command('help', self.add_help_arguments, self.run_help_command,
- help_msg='Print help of a subcommand')
self.add_command('rewrite', lambda parser: rewriter.add_arguments(parser, self.formatter), rewriter.run,
help_msg='Modify the project definition')
self.add_command('compile', mcompile.add_arguments, mcompile.run,
@@ -71,6 +69,9 @@ class CommandLineParser:
help_msg='Run commands in developer environment')
self.add_command('env2mfile', env2mfile.add_arguments, env2mfile.run,
help_msg='Convert current environment to a cross or native file')
+ # Add new commands above this line to list them in help command
+ self.add_command('help', self.add_help_arguments, self.run_help_command,
+ help_msg='Print help of a subcommand')
# Hidden commands
self.add_command('runpython', self.add_runpython_arguments, self.run_runpython_command,
@@ -109,7 +110,7 @@ class CommandLineParser:
return 0
def add_help_arguments(self, parser):
- parser.add_argument('command', nargs='?')
+ parser.add_argument('command', nargs='?', choices=list(self.commands.keys()))
def run_help_command(self, options):
if options.command: