From 3ed0063fa699d4b9c20cc591208c0254f730804d Mon Sep 17 00:00:00 2001 From: Gurkirat Singh Date: Sun, 10 Jan 2021 19:29:43 +0530 Subject: [PATCH] formatted lerna completion and used helper function --- completion/available/lerna.completion.bash | 32 ++++++++++++---------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/completion/available/lerna.completion.bash b/completion/available/lerna.completion.bash index 792ea27b..fb271f7e 100644 --- a/completion/available/lerna.completion.bash +++ b/completion/available/lerna.completion.bash @@ -1,19 +1,23 @@ #!/bin/bash # Lerna autocompletion. -function _lerna_completions() { - local cur compls - # The currently-being-completed word. - cur="${COMP_WORDS[COMP_CWORD]}" +if _command_exists lerna +then + function _lerna_completions() { + local cur compls - # Options - compls="add bootstrap changed clean create diff exec \ - import init link list publish run version \ - --loglevel --concurrency --reject-cycles \ - --progress --sort --no-sort --help \ - --version" + # The currently-being-completed word. + cur="${COMP_WORDS[COMP_CWORD]}" - # Tell complete what stuff to show. - COMPREPLY=($(compgen -W "$compls" -- "$cur")) -} -complete -o default -F _lerna_completions lerna + # Options + compls="add bootstrap changed clean create diff exec \ + import init link list publish run version \ + --loglevel --concurrency --reject-cycles \ + --progress --sort --no-sort --help \ + --version" + + # Tell complete what stuff to show. + COMPREPLY=($(compgen -W "$compls" -- "$cur")) + } + complete -o default -F _lerna_completions lerna +fi