Bug 865638

Summary: Bash completion does not always give sensible options
Product: [Retired] Beaker Reporter: Raymond Mancy <rmancy>
Component: command lineAssignee: beaker-dev-list
Status: CLOSED DUPLICATE QA Contact: tools-bugs <tools-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 0.9CC: jingwang, osabart, rebarbos, redhat.com, tools-bugs
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: CommandLineEnhancement
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2019-11-26 08:18:28 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Raymond Mancy 2012-10-11 23:54:59 UTC
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 08:38:51 UTC
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 05:45:49 UTC
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 16:29:16 UTC
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 22:27:32 UTC
(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 22:39:28 UTC
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 22:49:07 UTC
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.

Comment 10 John Villalovos 2019-10-02 19:03:07 UTC
This commit: https://github.com/beaker-project/beaker/commit/8f6fd28cd454a5bda9907fe9f763c9f9475394bf

Seems to solve the remaining issues mentioned in this bug. So once the current develop branch gets pushed to master, I would think this bug can be closed.

The original bug is already fixed.

Comment 4 issue: Is fixed with the mentioned commit.

Comment 2 issue: Is fixed with the mentioned commit. Doing "bkr workflow-simple --no<TAB>" only produces "--no-wait"

Comment 11 Renan Rodrigo Barbosa 2019-11-26 08:18:28 UTC

*** This bug has been marked as a duplicate of bug 1776324 ***