Closed aik099 closed 9 years ago
Hey @aik099, it's mentioned at the bottom of the readme that not showing suggestions for option shortcuts is intentional behaviour:
Option shortcuts are not offered as completion options, however requesting completion (ie. pressing tab) on a valid option shortcut will complete.
This mimics the completion behaviour used for many common programs that have both long and short form options (eg. ls
, cat
, grep
, rsync
, git
, curl
). There doesn't appear to be any official guideline/documentation on this subject, but aside from it being a sort of defacto standard, I'd argue that listing option shortcuts doesn't provide any useful information for people who aren't familiar with a program.
Obviously the shortcut listings would be in addition to the long form options, but I still think the value is limited. Consider these examples:
$ nc -[TAB][TAB]
-b -c -C -e -g -G -h -i -k -l -n -o -p -q -r -s -t -T -u -v -w -z
vs.
$ chgrp -[TAB][TAB]
-c -h -R -v
--changes --help --recursive --verbose
--dereference --no-dereference --reference --version
-f --quiet --silent
vs.
$ rsync --[TAB][TAB]
--8-bit-output --fake-super --only-write-batch=
--acls --files-from= --out-format=
--address= --filter= --owner
--append --force --partial
...
Option shortcuts can be combined into a single argument (see below), which will produce no completion currently.
This is mostly a limitation of the way BASH/ZSH completion works (as I understand it). Completion results are passed to these systems as a single string, which is then broken up into results using their list of word break characters. Since there are no "word break characters" between the shortcut characters in a string like -dak
, the only way to achieve this would be to return suggestions as additions to the current word:
program -[TAB]
: -a
, -d
, -k
program -d[TAB]
: -da
-dk
program -da[TAB]
: -dak
This is a bit ugly, and it would also conflict with options that take arguments; one would need to have priority. The behaviour of only suggesting options that haven't been used already is something I've considered in the past, but it's one of those things that might be more confusing that useful.
In general I don't see much utility in providing shortcuts as suggestions, but I'm interested to hear arguments for it.
No other arguments really. Just thought this was some not finished stuff and decided to report that just in case. For user to complete for 1 letter shortcuts he/she needs to press more symbols on keyboard then shortcut itself (TAB a BACKSPACE d ...), which makes auto-complete totally counter productive as you've noted above.
When I'm doing
program command-name --TAB
the possible option names are suggested.Problem 1 Unfortunately same doesn't work for option shortcuts, so when I'm doing
program command-name -TAB
no option shortcuts are suggested. Here is the debug info:Also there is something wrong with CLI input parsing because at point where we should be suggesting option shortcuts current word index is at space before
-
.Problem 2 Option shortcuts can be combined into a single argument (see below), which will produce no completion currently. So if a command has
a
,d
,k
shortcuts, then following should be suggested:program -TAB
- a, d, kprogram -dTAB
- a, kprogram -daTAB
- kprogram -da -TAB
- k