Shellac Protocol Proposal V2 - oils-for-unix/oils GitHub Wiki
- Back to Shell Autocompletion
- Original Shellac Protocol Proposal
Requirements
- Shell-agnostic. You can't force zsh to parse bash strings!
- Compatible with existing completion scripts. e.g.
_openstack
use case. Most migrations should be a trivial wrapper. - Probably: Should be implementable in pure bash and zsh.
Design Sketch
Compared to the original Shellac Protocol Proposal
- Remove mention of coprocesses! That is orthogonal. It's just a process now.
- Input side:
- shellac-provider -- command --myflag 1 --myflag2 f
- Output:
- { key, value, key, value } in NUL terminated strings
- Arrays are prefixed with length
Example:
["candidates", "2", "one", "two", "descriptions", "2", "desc1", "desc2"]
This is printed on stdout as a series of NUL-terminated strings.
- Read with
read -d $'\0'
in bash
Finding Completions for binaries
Look in $SHELLAC_HOME_DIR/plugins/openstack/complete
for openstack.
$SHELLAC_HOME
= ~/.local/shellac
on Linux.
TODO: details.
Extensibility
- Input format is extensible with new flags
- Output format is extensible with new "keys".
- right now we have
"candidates"
and"descriptions"
, but we can have more.
- right now we have
Migration
From bash completion
- Easy, just take COMPREPLY and print as "candidates". Descriptions are left blank.
From subcommands
- Easy, just write a shell wrapper:
#!/bin/sh
exec npm complete "$@"
complete -C
in bash?
What's Wrong with - line-oriented protocol
- COMP_CWORDS is wrong
TODO: Write up more!
Test Cases
See Shellac Test Cases.