Skip to content

Commit

Permalink
Fix leapp prints nothing when running with no args on python3.6.
Browse files Browse the repository at this point in the history
A change introduced in the stdlib argparse module accidentally caused
all subparsers to become optional instead of required as in python 2.7.
This change therefore causes leapp to print nothing and exit with error
code 0 when being executed without any arguments.

This commit marks the subparser action as required, so that the
python3.6 module recognizes this situation and prints the usage message.

To provide a meaningful message on python3.6 the subparser action was
edited to use 'command' metavar and the 'title' option was dropped.
  • Loading branch information
MichalHe committed Sep 2, 2021
1 parent 350ca36 commit dbfc496
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion leapp/utils/clicmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ def execute(self, version):
parser.add_argument('--version', action='version', version=version)
parser.set_defaults(func=None)
if self._sub_commands:
s = parser.add_subparsers(title='Main commands', metavar='')
s = parser.add_subparsers(title='Required arguments', metavar='command')
s.required = True
else:
s = parser
self.apply_parser(s, parser=parser)
Expand Down

0 comments on commit dbfc496

Please sign in to comment.