diff options
author | Prathamesh <yashlohakare48@outlook.com> | 2022-07-13 22:18:32 +0530 |
---|---|---|
committer | Eli Schwartz <eschwartz93@gmail.com> | 2022-07-17 00:45:26 -0400 |
commit | 7af0078d4e360c4b362b8ee73140e44b1c98205b (patch) | |
tree | a474a2df73c221977a77f5c74f4a6f2c171393c3 | |
parent | c7eb601e07f7840160a59555ada3980255e92f66 (diff) | |
download | meson-7af0078d4e360c4b362b8ee73140e44b1c98205b.zip meson-7af0078d4e360c4b362b8ee73140e44b1c98205b.tar.gz meson-7af0078d4e360c4b362b8ee73140e44b1c98205b.tar.bz2 |
Resolve KeyError while executing help command with unknown param
-rw-r--r-- | mesonbuild/mesonmain.py | 7 |
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: |