Red Hat Bugzilla – Bug 865638
Bash completion does not always give sensible options
Last modified: 2016-11-10 00:19:19 EST
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 )
reproduced on beaker-devel Version - 0.13.2
bkr client on Fedora 17
$bkr --password --<tab>
--help --help] --hub --password --username
The other problem is with aliased options, for example:
$ bkr workflow-simple --no
The fix is probably the same. Another possible fix to consider is switching to:
which might also improve the very sluggish completion speed.
The completion for files in "brk job-submit" doesn't work either.
$ touch foo.xml
$ bkr job-submit fo<TAB>
Should I open new bug report?
(In reply to Otto Sabart from comment #4)
Thanks Otto, no need for a separate bug at this point, we can cover it here.
Lately I have been tempted by Armin Ronacher's Click library for CLIs  to replace the stuff we inherited from Kobo. Handily it has support for generating bash completion  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...
The move to Click has fallen by the wayside a little, but I have posted a patch to deal with the simplest problems above.
This bug will stay open for now since that patch doesn't address all the problems identified here.