Bug #7123
openhammer doesn't accept arbitrary order of arguments
Description
Cloned from https://bugzilla.redhat.com/show_bug.cgi?id=1130551
Description of problem:
I try to use hammer and I don't know what is correct order of arguments.
for example:
hammer -p changeme -u admin --csv content-host list --organization-id 1
ID,Name
7097a1fc-713f-429c-bf99-6914a79243e4,cisco-c210-01.rhts.eng.bos.redhat.com
hammer --csv -p changeme -u admin content-host list --organization-id 1
[Foreman] password for admin:
(empty result)
hammer --password changeme -u admin content-host list --organization-id 1 --csv
Error: Unrecognised option '--csv'
See: 'hammer content-host list --help'
Version-Release number of selected component (if applicable):
rubygem-hammer_cli_katello-0.0.4-10.el6sat.noarch
rubygem-hammer_cli-0.1.1-11.el6sat.noarch
rubygem-hammer_cli_foreman-0.1.1-15.el6sat.noarch
rubygem-hammer_cli_foreman_tasks-0.0.3-3.el6sat.noarch
How reproducible:
always
Actual results:
Magic with ordering arguments
Expected results:
Accept arbitrary order of arguments
Updated by Tomáš Strachota over 9 years ago
Options -u and -p are pre-parsed during hammer's startup. Pre-parser does not recognize --csv and stops parsing which results in -u/-p being unknown.
Preparser needs to skip unknown options. I think we should also limit pre-parsing only to --config and move rest of the setup logic into HammerCLI::MainCommand. It will enable for specifying custom options for credentials from plugins.