From fb15797b6824b1ab72535aabb396b3de57e2e5d6 Mon Sep 17 00:00:00 2001 From: Ondrej Nosek Date: Nov 27 2018 16:54:56 +0000 Subject: Move argparse fix from fedpkg The fix is valid also for rhpkg and moving it to rpkg will prevent code duplication. Fixes: #398 Signed-off-by: Ondrej Nosek --- diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py index 08755f7..32a9cbe 100644 --- a/pyrpkg/cli.py +++ b/pyrpkg/cli.py @@ -2378,6 +2378,14 @@ see API KEY section of copr-cli(1) man page. # Parse the args self.args = self.parser.parse_args() + # This is due to a difference argparse behavior to Python 2 version. + # In Python 3, argparse will proceed to here without reporting + # "too few arguments". Instead, self.args does not have attribute + # command. + if not hasattr(self.args, 'command'): + self.parser.print_help() + sys.exit(1) + if self.args.module_name and self.args.repo_name: self.parser.error( 'argument --name: not allowed with --module-name')