Bug 862932 - command line parser should exit gracefully if user typed in the an invalid optioin
command line parser should exit gracefully if user typed in the an invalid op...
Status: CLOSED CURRENTRELEASE
Product: OpenShift Origin
Classification: Red Hat
Component: Command Line Interface (Show other bugs)
2.x
Unspecified Unspecified
unspecified Severity low
: ---
: ---
Assigned To: John (J5) Palmieri
libra bugs
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-10-03 19:44 EDT by Peter Ruan
Modified: 2015-05-14 22:06 EDT (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2012-11-06 13:50:07 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Peter Ruan 2012-10-03 19:44:28 EDT
Description of problem:
  The CLI tool should be able to handle the case in which a user typed an invalid option and exist gracefully instead of printing an exception like below.

Version-Release number of selected component (if applicable):
rhc (0.99.3)

How reproducible:
 rhc domain create -a pythonapp -t python-2.6 -pvostok08 -d

Steps to Reproduce:
1.
2.
3.
  
Actual results:
[pruan@homer-linux .openshift]$ rhc domain create -a pythonapp -t python-2.6 -pvostok08 -d
/usr/local/share/gems/gems/commander-4.1.2/lib/commander/command.rb:169:in `parse_options_and_call_procs': invalid option: -a (OptionParser::InvalidOption)
        from /usr/local/share/gems/gems/commander-4.1.2/lib/commander/command.rb:155:in `run'
        from /usr/local/share/gems/gems/commander-4.1.2/lib/commander/runner.rb:402:in `run_active_command'
        from /usr/local/share/gems/gems/rhc-0.99.3/lib/rhc/command_runner.rb:55:in `run!'
        from /usr/local/share/gems/gems/commander-4.1.2/lib/commander/delegates.rb:11:in `run!'
        from /usr/local/share/gems/gems/rhc-0.99.3/lib/rhc/cli.rb:40:in `start'
        from /usr/local/share/gems/gems/rhc-0.99.3/bin/rhc:63:in `<top (required)>'
        from /usr/local/bin/rhc:23:in `load'
        from /usr/local/bin/rhc:23:in `<main>'


Expected results:
parser should return a more user friendly error message with help text.

Additional info:
Comment 1 John (J5) Palmieri 2012-10-04 10:09:46 EDT
Fixed in fork
Comment 2 Chandrika Gole 2012-10-04 18:03:13 EDT
verified in fork AMI: fork_ami_US2597_US2599_US2813_US2817_US2872_US2816_US2814_207 (ami-a50eb3cc)

[root@ip-10-114-57-95 ~]# rhc domain create -a pythonapp -t python-2.6 -pvostok08 -d
invalid option: -a

Usage: rhc domain create <namespace>

Define a namespace for your applications to share.

Options for domain create
  -n, --namespace namespace Namespace for your application(s) (alphanumeric)

Global Options
  -l, --rhlogin login       OpenShift login
  -p, --password password   OpenShift password
  -d, --debug               Turn on debugging
  --noprompt                Do not ask for input
  --config FILE             Path of a different config file
  -h, --help                Display help documentation
  -v, --version             Display version information
  --timeout seconds         Set the timeout in seconds for network commands

Note You need to log in before you can comment on or make changes to this bug.