On 11/14/2018 03:12 AM, Lin Ma wrote:
Hi all,

These draft patches add the tab completion in bash for virt-* utilities.

We've been using the argparse to help parse handling, So I think that the
argcomplete is a good option to deal with argument/sub-options completion
in bash shell for virt-manager project. Argcomplete returns the completion
result via fd 8.
After applying these patches, The python3 argcomplete is required while
running virt-* utilities.

For the details about argcomplete, Please refer to:
https://github.com/kislyuk/argcomplete  or
https://pypi.org/project/argcomplete/


Wow, nice work! I didn't expect this to be so minimally invasive. I haven't heard of argcomplete, it's a handy project for sure.

ex:
$ virt-clone --<TAB><TAB>
...
--auto-clone     --debug    --help     --nonsparse    --reflink
--check          --file     --mac      --nvram        --replace
...

$ virt-install --p<TAB><TAB>
--panic      --parallel   --paravirt   --pm         --print-xml  --pxe

$ virt-install --panic <TAB><TAB>
clearxml=  iobase=    model=

$ virt-install --panic model=isa,<TAB><TAB>
clearxml=  iobase=

$ virt-install --disk <TAB><TAB>
...
bus=    cache=      format=     path=   serial=     size=
...

$ virt-install --disk 
path=/storage/vms/sles15/disk0.raw,format=raw,<TAB><TAB>cache=none
...
bus=    format=     serial=     path=   size=
...


$ virt-install --network model=rtl8139,ty<TAB><TAB>
$ virt-install --network model=rtl8139,type=


* A side effect of patches is:
Due to the sub options of arguments of virt-* is comma separated, It needs
to add comma into $COMP_WORDBREAKS to support sub options completion.
That means, Once we used TAB for option completion, The change impacts the
current shell.


I barely looked at this so I don't fully understand the issue, but we definitely can't change shell behavior after some tab completion attempts. Maybe this helps finding a better solution?

https://stackoverflow.com/questions/10528695/how-to-reset-comp-wordbreaks-without-affecting-other-completion-script

I'll comment on some of the patches individually

Thanks,
Cole

_______________________________________________
virt-tools-list mailing list
virt-tools-list@redhat.com
https://www.redhat.com/mailman/listinfo/virt-tools-list

Reply via email to