enable tab completion for some parameters

Bug #936423 reported by Joseph Heck
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-keystoneclient
Won't Fix
Wishlist
Unassigned

Bug Description

tab completion of commands/flags and uuids :) Ewan did uuid completion for the xs utility. Makes a huge difference. Yep, 'xe' completes EVERYTHING and it is the best

Revision history for this message
Joseph Heck (heckj) wrote :

I wrote Ewan for some details on how he did his work:

https://github.com/xen-org/xen-api/blob/master/ocaml/xe-cli/bash-completion

(and other files in that folder).

The trick we used was basically to have the server able to return
machine-readable command lists, and parameter lists per command, so that
we could tab-complete in all the right ways. Take a look for ${xe} help,
it's used a few times.

That let us tab-complete the various command names, and then type-specific
parameters (so foo= for a key-value pair that will eventually be foo=val,
or foo: for a dictionary entry that will eventually be foo:key=val).

It also gives us the types of the right-hand sides, so we know whether we're
tab-completing a VM selector (name or UUID) or just a VM UUID, or some
arbitrary value. Object selectors are typed, so we have VM selectors separate
from host selectors, etc.

In retrospect, I wish that we'd added a 'pre-escaped bash strings' mode to
the server, because one of the hardest bits is just getting the escaping
and word-splitting right (and it's not perfect even today). We should have
just got the server to send us everything escaped the right way, rather
than the collection of seds and variable substitutions that you see in
compgen_names and compgen_escape and elsewhere. As well as the complexity,
I'd hate to think how many subprocesses are forked every time the user hits
tab.

There's an interesting changeset that I've just spotted (it post-dates me)
that says that bash 4 changed the word-splitting rules. You'll want to
read that one.

Cheers,

Ewan.

On Sun, Feb 19, 2012 at 06:23:02PM -0000, Joseph Heck wrote:

Hey Ewan,

One of the bugs I just logged in from some discussion notes mentioned
you (I think it was you anyway) - related to the idea that you had done
some enabling tab-completion in a CLI environment:

   https://bugs.launchpad.net/keystone/+bug/936423

Does this ring any bells? If so, would you mind sending me a quick
pointer to the code that you did that to (because I totally want to
steal how you did it...)

Dolph Mathews (dolph)
Changed in keystone:
importance: Undecided → Wishlist
Thierry Carrez (ttx)
affects: keystone → python-keystoneclient
Dolph Mathews (dolph)
tags: removed: python-keystoneclient
Revision history for this message
Steve Martinelli (stevemar) wrote :

CLI for keystoneclient has been deprecated, use openstackclient, it comes with serious tab completion capabilities

marking as won't fix

Changed in python-keystoneclient:
status: Confirmed → Won't Fix
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.