Tab Autocompletion migrate to bash#178
Tab Autocompletion migrate to bash#178ikifar2012 wants to merge 10 commits intohome-assistant:masterfrom
Conversation
…d handling of command line inputs
…wn commands are handled by 'ha'
sairon
left a comment
There was a problem hiding this comment.
There are quite some comments below but it's mostly about cleaning up the slop, in overall I like the change and in quick testing it works as intended.
| # Friendly helpers | ||
| help() { | ||
| echo 'Note: Use "login" to enter operating system shell' | ||
| echo '' | ||
| echo '--------------------------------' | ||
| ha help | ||
| } | ||
| login() { | ||
| echo 'Entering OS shell...' | ||
| exit 10; | ||
| } |
|
|
||
| # Wrapper function to inject 'ha' as first argument for all completions | ||
| if declare -F __start_ha >/dev/null 2>&1; then | ||
| __start_ha >/dev/null 2>&1 || true |
|
|
||
| # Universal completion handler - wraps everything as 'ha ...' | ||
| __ha_repl_complete() { | ||
| local cur prev words cword |
There was a problem hiding this comment.
These variables are not used anywhere.
| # CLI for the Home Assistant Operating System | ||
|
|
||
| This is for the Home Assistant Operating System and is the login shell. | ||
| This is for the Home Assistant Operating System and is the login shell. No newline at end of file |
There was a problem hiding this comment.
Nit; but looks like some newline issue after the revert, this change shouldn't be here.
| build-base \ | ||
| readline-dev \ | ||
| ncurses-dev \ | ||
| && curl -L -s "https://github.com/hanslub42/rlwrap/releases/download/${RLWRAP_VERSION}/rlwrap-${RLWRAP_VERSION}.tar.gz" \ |
There was a problem hiding this comment.
Removing this makes RLWRAP_VERSION in the build.yaml obsolete.
| && rm -rf /usr/src/* | ||
| # Install dependencies | ||
| RUN apk add --no-cache \ | ||
| bash-completion |
There was a problem hiding this comment.
Do we need to install it, since it'll be nuked by https://github.com/home-assistant/plugin-cli/pull/178/changes#diff-6b273e2dc8569a3bc4c5e043308422c2c86cc96536be27415f116d33c1a5fe9dR42-R45 anyway?
There was a problem hiding this comment.
It provides some of the functions used by the completion script, I'll take another look but pretty sure its needed
|
|
||
| # Run CLI | ||
| COMMAND="" | ||
| while true; do |
There was a problem hiding this comment.
Previously EOF (Ctrl+D) didn't exit this loop, while it does exit the REPL in the current implementation. We should also set set -o ignoreeof so only Ctrl+C exits it.
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
This is just a proof of concept I have been playing around with, this aims to add tab completion to make the experience feel a bit more polished. I feel tab completion is an absolute must when trying to debug at a physical console