suggest commands if command is not recognized

Bug #1462192 reported by Rushi Agrawal
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
cliff
Fix Released
Undecided
Ayakashi
python-openstackclient
Invalid
Wishlist
Unassigned

Bug Description

A usability issue, and maybe a wishlist bug, but it would be really great if for example when a user types

openstack user

then we tell the user that the command needs another word as an argument, and the possible words are 'list', 'create', 'delete'.

Revision history for this message
Amey Bhide (abhide) wrote :

tab-completion spits out the arguments

$ openstack user <tab>

create delete list role set show

Can you check with the latest python-openstackclient?

Revision history for this message
Rushi Agrawal (rushiagr) wrote :

@Amey, you're right, the tab completion works. But even then, if I type 'openstack user', it says:

ERROR: openstack Unknown command ['user']

'user' definitely is not an unknown command. At the very least, it should be worded better. Better would be if it says 'user' needs another argument out of these: create delete list role set show

Revision history for this message
Steve Martinelli (stevemar) wrote :

not sure how to fix this, but its definitely bad UX (even with tab completion). Wishlisting.

Changed in python-openstackclient:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Ayakashi (guowang) wrote :

@Steve maybe can get experience from keystoneclient,

if i type 'keystone user-get', it says:

keystone user-get <tab>
usage: keystone user-get <user>
keystone user-get: error: too few arguments

Revision history for this message
Ayakashi (guowang) wrote :

@Amey i just used the latest python-openstackclient (at branch 'stable/kilo'), but the tab-completion is not useful...
ps. i installed openstack with devstack

heha (zhanghanqun)
Changed in python-openstackclient:
assignee: nobody → heha (zhanghanqun)
Revision history for this message
heha (zhanghanqun) wrote :

I think this problem should be solved in the "cliff".

Ayakashi (guowang)
Changed in python-openstackclient:
assignee: heha (zhanghanqun) → kafka (guowang)
Revision history for this message
Ayakashi (guowang) wrote :

see how 'openstack <cmd> help' work , maybe can got some spark
the code is at cliff/help.py

1> exact match
$ openstack user list help
usage: openstack user list [-h] [-f {csv,html,json,table,value,yaml}]
                           [-c COLUMN] [--max-width <integer>]
                           [--quote {all,minimal,none,nonnumeric}]
                           [--project <project>] [--long]
openstack user list: error: unrecognized arguments: help

2> fuzzy match
$ openstack user help
Command "user" matches:
  user create
  user delete
  user list
  user role list
  user set
  user show

compare with 'openstack user', there not raise a ValueError,
but try to find a fuzzy match and print it out
good UX!

3> not match
$openstack usre help
ERROR: openstack Unknown command ['usre', 'help']

so, when type 'openstack user':
     1> try to find an exact match; (obviously, can't find )
     2> try to find a fuzzy match; it could be:
              ' openstack user list'
              'openstack user show'
              'openstack user create'
               ...
     3> if also can't fuzzy match , raise ValueError(if debug) or log error

Revision history for this message
Ayakashi (guowang) wrote :
Changed in python-openstackclient:
assignee: kafka (guowang) → nobody
Changed in python-cliff:
assignee: nobody → kafka (guowang)
status: New → Fix Committed
status: Fix Committed → In Progress
jiaxi (tjxiter)
Changed in python-openstackclient:
assignee: nobody → jiaxi (tjxiter)
Changed in python-cliff:
assignee: kafka (guowang) → Steve Martinelli (stevemar)
Changed in python-cliff:
assignee: Steve Martinelli (stevemar) → kafka (guowang)
jiaxi (tjxiter)
Changed in python-openstackclient:
assignee: jiaxi (tjxiter) → nobody
Revision history for this message
Terry Howe (thowe-g) wrote :

Marked the OSC part invalid as I think the cliff change will fix that.

Changed in python-openstackclient:
status: Confirmed → Invalid
Revision history for this message
Steve Martinelli (stevemar) wrote :

@terry, i was hoping to keep it as valid for OSC, so we could track when we depend on a new cliff :)

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to cliff (master)

Reviewed: https://review.openstack.org/202053
Committed: https://git.openstack.org/cgit/openstack/cliff/commit/?id=3396764571f5e18f99a63f1f1160a0a6a1b3097a
Submitter: Jenkins
Branch: master

commit 3396764571f5e18f99a63f1f1160a0a6a1b3097a
Author: kafka <email address hidden>
Date: Wed Jul 15 16:16:36 2015 +0800

    Add command fuzzy matching

    The command 'openstack user' throws error with no helpful message even though 'openstack user list' works,
    that is really a bad UX. This patch adds fuzzy matching to print the most similar command when user mistypes
    the command.
    Use Demeraou-Levenshtein algorithm to find the best similarity. It takes experience from Git's
    algothrim inplement https://github.com/git/git/commit/8af84dadb142f7321ff0ce8690385e99da8ede2f

    $ openstack user
    openstack: 'user' is not an openstack command. See 'openstack --help'.
    Did you mean one of these?
      user create
      user delete
      user list
      user password set
      user set
      user show
      consumer create
      consumer delete
      consumer list
      consumer set
      consumer show

    Change-Id: Id8732504c0b36177319fc33fae7e630b7b714be7
    Closes-Bug: 1462192

Changed in python-cliff:
status: In Progress → Fix Committed
summary: - 'openstack user' throws error with no helpful message, even though
- 'openstack user list' works
+ suggest commands if command is not recognized
Changed in python-cliff:
milestone: none → 1.14.0
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.