From 75e652a9437930d11930ce177a7828eb5319ece3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Doktor?= Date: Tue, 29 May 2018 08:20:36 +0200 Subject: [PATCH] parser: Suggest installing plugins on missing command MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Many arguments are provided by plugins, let's suggest checking the installed plugins on unrecognized argument to raise awareness of the need to install additional plugins which might help people that see Avocado for the first time. Signed-off-by: Lukáš Doktor --- avocado/core/parser.py | 3 +++ selftests/functional/test_argument_parsing.py | 1 + 2 files changed, 4 insertions(+) diff --git a/avocado/core/parser.py b/avocado/core/parser.py index 5274f473..f2e9da09 100644 --- a/avocado/core/parser.py +++ b/avocado/core/parser.py @@ -39,6 +39,9 @@ class ArgumentParser(argparse.ArgumentParser): def error(self, message): LOG_UI.debug(self.format_help()) LOG_UI.error("%s: error: %s", self.prog, message) + if "unrecognized arguments" in message: + LOG_UI.warning("Perhaps a plugin is missing; run 'avocado" + " plugins' to list the installed ones") self.exit(exit_codes.AVOCADO_FAIL) def _get_option_tuples(self, option_string): diff --git a/selftests/functional/test_argument_parsing.py b/selftests/functional/test_argument_parsing.py index 2a2176c5..6f104eef 100644 --- a/selftests/functional/test_argument_parsing.py +++ b/selftests/functional/test_argument_parsing.py @@ -42,6 +42,7 @@ class ArgumentParsingTest(unittest.TestCase): subcommand_error_msg = (b'avocado run: error: unrecognized arguments: ' b'--whacky-argument') self.assertIn(subcommand_error_msg, result.stderr) + self.assertIn(b"run 'avocado plugins'", result.stderr) class ArgumentParsingErrorEarlyTest(unittest.TestCase): -- GitLab