A crystal library for creating easy prompting cli tools in crystal. I wanted a prompting kit with easy to use tab completion/suggestion while also having a nice easy hierarchy for the suggestion table. Cryprompt also now features a suggestion description in its table with the opional _description
option inside the json or yaml configuration
I am completely open to fixes and suggestions. If there is a better way to do anything i have done please let me know!!
- Text box suggestions
- easy suggestion path implementaion via yaml/json
- tab complete
- multiple suggestions
- description options
The flow of suggested material is in the form of a hash and can be written in json or yaml quite easily.
ex.
hello:
_description: this is a descroption for hello
to:
- you
- jeff
- jessie
- jane
world:
everyone:
_description: this is a description for everyone
with:
a:
_description: this is a description for "a" after "with"
- hat
- shirt
- shoes
- pants
The word "hello" defines the base of this tree and will have 2 sub suggestions "to" and "world".
run the demo program below
git clone https://github.com/CausticKirbyZ/cryprompt.git
cd cryprompt
make && ./bin/demo
-
Add the dependency to your
shard.yml
:dependencies: cryprompt: github: CausticKirbyZ/cryprompt branch: master
-
Run
shards install
require "cryprompt"
- UPDATE AND DOCUMENT!!!!!! (fix crystal docs) cuz i will come back later and go what was i doing....
- The code is fairly messy.. should be cleaned up
hitting tab will autocomplete if only 1 suggestion exists- expose some options to change the autoprompt box color (also address the colored text issues...)
refactor the autocomplete class to use escape codes for faster/easier cursor management- move methods that dont need to be exposed to private
do some sort of window size detection so no suggestions are shown unless there is appropriate window size(mostly... could be better but does work)- windows compatability?? (would probably need to write a different get_char function based on the WM_SYSKEYDOWN function?) will wait on crystal to support windows?
- pasting with multiple lines is broken. - not sure how to fix...
- colored prompts will break the location of the cursor apearance due to color codes taking string space... need to fix that
- Fork it (https://github.com/your-github-user/cryprompt/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- CausticKirbyZ - creator and maintainer
These 2 repos. I didnt use any of their code but took inspiration on how i wanted the prompt for this library to look