Bug 865638 - Bash completion does not always give sensible options
Bash completion does not always give sensible options
Status: ASSIGNED
Product: Beaker
Classification: Community
Component: command line (Show other bugs)
0.9
Unspecified Unspecified
unspecified Severity unspecified (vote)
: ---
: ---
Assigned To: Dan Callaghan
tools-bugs
CommandLineEnhancement
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2012-10-11 19:54 EDT by Raymond Mancy
Modified: 2016-11-10 00:19 EST (History)
7 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
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 Raymond Mancy 2012-10-11 19:54:59 EDT
The bash completion of 'bkr' lists '--password' as an option, bash completion of
'bkr --password' lists the following

[rmancy@rmancy ~]$ bkr --password --
--help      --help]     --password  --username 

Notice the '--help]'. Also, none of these completions actually render a sensible command.


The below Comment is from Filip Holec on how to fix it(thanks!):

This should fix it:

<local opts=$(echo $( bkr $component --help 2>/dev/null | grep -o -- '--[^ =]*' | sort | uniq ) --help )
>local opts=$(echo $( bkr $component --help 2>/dev/null | grep -v "Usage:"  | grep -o -- '--[^ =]*' | sort | uniq ) --help )
Comment 2 wangjing 2013-07-04 04:38:51 EDT
reproduced on beaker-devel Version - 0.13.2
bkr client on Fedora 17

Actual results:
$bkr --password --<tab>
 --help      --help]     --hub       --password  --username
Comment 3 Dan Callaghan 2013-07-09 01:45:49 EDT
The other problem is with aliased options, for example:

$ bkr workflow-simple --no
--nowait    --no-wait,  

The fix is probably the same. Another possible fix to consider is switching to:

http://furius.ca/optcomplete/

which might also improve the very sluggish completion speed.
Comment 4 Otto Sabart 2014-09-15 12:29:16 EDT
The completion for files in "brk job-submit" doesn't work either.

Example:
$ touch foo.xml
$ bkr job-submit fo<TAB>
....gives nothing.

Should I open new bug report?
Comment 5 Dan Callaghan 2014-09-15 18:27:32 EDT
(In reply to Otto Sabart from comment #4)

Thanks Otto, no need for a separate bug at this point, we can cover it here.
Comment 6 Dan Callaghan 2014-09-15 18:39:28 EDT
Lately I have been tempted by Armin Ronacher's Click library for CLIs [1] to replace the stuff we inherited from Kobo. Handily it has support for generating bash completion [2] although it is apparently not customizable and looks like it is not smart enough to be able to complete filenames for positional arguments when appropriate...

[1] http://click.pocoo.org/
[2] http://click.pocoo.org/3/bashcomplete/
Comment 8 Dan Callaghan 2015-02-26 17:49:07 EST
The move to Click has fallen by the wayside a little, but I have posted a patch to deal with the simplest problems above.

http://gerrit.beaker-project.org/4006

This bug will stay open for now since that patch doesn't address all the problems identified here.

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