Closed Blacksmoke16 closed 1 year ago
Wow! Incredible!
@paulocoghi Is still some work to do (mainly adding the other shells and augmenting existing commands), but feel free to try it out and let me know if you have any issues/suggestions.
I will try it and let you know!
Implements command tab completion by leveraging the shell's built in completion features. Currently only
bash
is supported, butfish
andzsh
can/will be added in another PR. Command and option names are supported out of the box. Option/argument values can be defined by using the newsuggested_values
option when adding arguments/options which accepts either anEnumerable(String)
or a block that should return anArray(String)
if additional filtering is desired. The#complete
method may also be overridden for more complex usages.This functionality does require sourcing/placing a generated file in a location where you shell is able to read it. E.g. sourced within
~/.bashrc
or placed within/etc/bash_completion.d/
. This is a one-time setup, so not too big of a deal.This can be done via the
completion
command that is bundled in with all console applications. E.g../console completion > completion.sh
. Run./console help completion
formore information.The name of the binary used to generate the script is important. In this case,
completion.sh
would handle auto completion for a binary calledconsole
, but not one called something else.The completion script also is required to run with real binaries, not via like
crystal run src/console.cr -- completion
.assert_command_is_successful
to the*Tester
typesResolves #293