From 5da7c18f1fc94e5eae6e6a52866921faf7891643 Mon Sep 17 00:00:00 2001 From: Franz Chih-Ping Hsieh Date: Thu, 16 Nov 2017 11:08:49 -0500 Subject: [PATCH] add argument detection to prevent array out of index error. Fixes: #706 https://pagure.io/koji/issue/706 --- cli/koji_cli/commands.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cli/koji_cli/commands.py b/cli/koji_cli/commands.py index f9a59dea..c4a0a222 100644 --- a/cli/koji_cli/commands.py +++ b/cli/koji_cli/commands.py @@ -7005,9 +7005,12 @@ def anon_handle_search(options, session, args): parser.add_option("-r", "--regex", action="store_true", help=_("treat pattern as regex")) parser.add_option("--exact", action="store_true", help=_("exact matches only")) (options, args) = parser.parse_args(args) - if not args: - parser.print_help() - return + if len(args) < 1: + parser.error(_("Please specify search type")) + assert False # pragma: no cover + if len(args) < 2: + parser.error(_("Please specify search pattern")) + assert False # pragma: no cover type = args[0] if type not in _search_types: parser.error(_("Unknown search type: %s") % type)