-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to use this module #33
Comments
0. Create a folder called
1. Create a file called
2. Put the following code into console.log('Hello i am the program'); 3. Run it to see it's working:
4. Install
5. Require it in your program: var omelette = require('omelette');
console.log('Hello i am the program'); 6. Initialize omelette: var omelette = require('omelette');
// initialize
omelette('hello <name> <surname>').init();
console.log('Hello i am the program'); 7. See if it works:
This should generate an output like this: ### hello completion - begin. generated by omelette.js ###
if type compdef &>/dev/null; then
_hello_completion() {
compadd -- `hello --compzsh --compgen "${CURRENT}" "${words[CURRENT-1]}" "${BUFFER}"`
}
compdef _hello_completion hello
elif type complete &>/dev/null; then
_hello_completion() {
local cur prev nb_colon
_get_comp_words_by_ref -n : cur prev
nb_colon=$(grep -o ":" <<< "$COMP_LINE" | wc -l)
COMPREPLY=( $(compgen -W '$(hello --compbash --compgen "$((COMP_CWORD - (nb_colon * 2)))" "$prev" "${COMP_LINE}")' -- "$cur") )
__ltrim_colon_completions "$cur"
}
complete -F _hello_completion hello
fi
### hello completion - end ### 8. Alias the command: But as you can see, this bash script tries to call an executable called
Let's test if it works:
9. Run the completion bash script that generated by Omelette (follow https://github.com/f/omelette#manual-installation): (I'm using Fish shell so I'm running:)
10. Edit index.js to complete the completion logic: var omelette = require('omelette');
var completion = omelette('hello <name> <surname>')
// This is your logic
completion.on('name', ({reply}) => { reply(['fatih', 'rotimi']) });
completion.on('surname', ({reply}) => { reply(['akin', 'best']) });
completion.init();
console.log('Hello i am the program'); 11. See if it works:
That's all. |
Thanks man for the explanation. It seems too much of a process for my use case. I just need a simple module that can help me make when I want to run |
I am closing this issue because I discovered now that I just need to type Thanks for the detailed answer BTW. |
Just a tip in case anyone runs into this: the alias + completion doesn't seem to quite work in zsh, at least for me. I think it might be more robust to use a function: |
I don't understand where the code from
Get started
should be placed and how do I get the auto completion functional in my terminal. It isn't clear enough how to get started using this module practically.Thanks.
The text was updated successfully, but these errors were encountered: