oamg / leapp

Leapp - Application & OS Modernization Framework (For in-place upgrades, follow leapp-repository)
https://oamg.github.io/leapp/
Apache License 2.0
87 stars 70 forks source link

Fix leapp prints nothing when running with no args on python3.6+ #731

Closed MichalHe closed 3 years ago

MichalHe commented 3 years ago

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.

Tasks to be done:

centos-ci commented 3 years ago

Can one of the admins verify this patch?

github-actions[bot] commented 3 years ago

Thank you for contributing to the Leapp project!

Please note that every PR needs to comply with the Leapp Guidelines and must pass all tests in order to be mergable. If you want to re-run tests or request review, you can use following commands as a comment:

Please open ticket in case you experience technical problem with the CI. (RH internal only)

Note: In case there are problems with tests not being triggered automatically on new PR/commit or pending for a long time, please consider rerunning the CI by commenting leapp-ci build (might require several comments). If the problem persists, contact leapp-infra.

leapp-bot commented 3 years ago

This PR has been linked in issue tracker (#OAMG-5488).

MichalHe commented 3 years ago

The usage message running python2.7 without any arguments is changed by this PR to (notice the added metavar command):

usage: leapp [-h] [--version] command ...

Optional arguments:
  -h, --help  show this help message and exit
  --version   show program's version number and exit

Required arguments:
  command
    answer    Manage answerfile generation: register persistent user choices
              for specific dialog sections
    upgrade   Upgrade the current system to the next available major version.
    list-runs
              List previous Leapp upgrade executions
    preupgrade
              Generate preupgrade report
    rerun     Re-runs the upgrade from the given phase and using the
              information and progress from the last invocation of leapp
              upgrade.
error: too few arguments

Running leapp with no arguments on python3.6 outputs (with exit code 2):

usage: leapp [-h] [--version] command ...

Optional arguments:
  -h, --help  show this help message and exit
  --version   show program's version number and exit

Required arguments:
  command
    answer    Manage answerfile generation: register persistent user choices
              for specific dialog sections
    list-runs
              List previous Leapp upgrade executions
    preupgrade
              Generate preupgrade report
    rerun     Re-runs the upgrade from the given phase and using the
              information and progress from the last invocation of leapp
              upgrade.
    upgrade   Upgrade the current system to the next available major version.
error: the following arguments are required: command