feat: unified autocomplete entrypoint #58
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Describe your changes
The core exposes a function
proposeCompletions
that is responsible for generating a set of completions for the given app + inputs. However, there needs to be some "glue" to adapt that function for each shell. At the moment, the only shell that's supported isbash
(but that is going to change). Currently the "glue" is written into the new application template, which makes it virtually impossible to change and it is only implementing thebash
"glue".This PR adds a new
handleCompletionsForShell
function to@stricli/auto-complete
that accepts the same args asproposeCompletions
AND the kind of shell. It then handles the "glue" for that specific shell kind and resolves async. This will allow for changes to this logic to be handled "internally" to these packages, and doesn't require any application-owner changes to support a new shell (once it is supported by@stricli/auto-complete
). To this end, there are newinstall-all
anduninstall-all
commands that will attempt to install/uninstall the autocomplete functionality for every supported shell all at once.Testing performed
Unit tests exercise the new behavior of
@stricli/auto-complete
forbash
that handles editing the.bashrc
and generating the completions (making sure the inputs and outputs are correct). There are also changes to the@stricli/create-app
baselines to account for the changes in autocomplete handling.These changes were also confirmed manually by generating a new application with
@stricli/create-app
and verifying the behavior in abash
shell.