Bug 862932 - command line parser should exit gracefully if user typed in the an invalid optioin
Summary: command line parser should exit gracefully if user typed in the an invalid op...
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: OKD
Classification: Red Hat
Component: oc
Version: 2.x
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
: ---
Assignee: John (J5) Palmieri
QA Contact: libra bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-10-03 23:44 UTC by Peter Ruan
Modified: 2015-05-15 02:06 UTC (History)
4 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-11-06 18:50:07 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Peter Ruan 2012-10-03 23:44:28 UTC
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 14:09:46 UTC
Fixed in fork

Comment 2 Chandrika Gole 2012-10-04 22:03:13 UTC
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.