Skip to content

Instantly share code, notes, and snippets.

@baflo
Last active August 12, 2019 09:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baflo/313e3ffa2632427d8916d87d7bb4e6d8 to your computer and use it in GitHub Desktop.
Save baflo/313e3ffa2632427d8916d87d7bb4e6d8 to your computer and use it in GitHub Desktop.
zsh completions
#compdef _lerna lerna
#http://zsh.sourceforge.net/Doc/Release/Completion-System.html#Completion-System
function _lerna {
local line
_arguments -C \
"--version" \
"--loglevel[Set the log output level]:level:(silent info warn error)" \
"--concurrency[How many processes to use when lerna parallelizes tasks]" \
"1: :(add bootstrap changed clean create diff exec \
import init link list publish run version)" \
"*::arg:->args"
case ${line[1]} in
clean)
_lerna_clean
;;
create)
_lerna_create
;;
esac
case ${line[1]} in
clean|exec|run|bootstrap)
_lerna_opts
;;
esac
}
function _lerna_opts {
_arguments -C \
"--help" \
"--scope[select the package of interest]:package:->packages" \
"--ignore[select packages to ignore]:package:->packages" \
"--include-filtered-dependencies[include dependencies of scoped package]" \
"--include-filtered-dependents[include packages that depend on scoped package]" \
"--no-private" \
"--since[Only include packages that have been updated since the specified \[ref\].]:tag:->revs"
case "$state" in
packages)
_values $(lerna ls --loglevel=silent -a 2> /dev/null | awk '{print $1}' | tr "\n" " ")
;;
revs)
_values $(git rev-list --max-count=10 HEAD | tr "\n" " ")
;;
esac
}
function _lerna_create {
_arguments -C \
"--access[When using a scope, set publishConfig.access value]:choices:(public restricted)" \
"--bin[Package has an executable. Customize with --bin <executableName>]" \
"--description[Package description]" \
"--dependencies[A list of package dependencies]" \
"--keywords[A list of package keywords]" \
"--private[Make the new pacakge private]" \
"--registry[Configure the package's publishConfig.registry]" \
"--tag[Configure the package's publishConfig.tag]" \
{-y,--yes}"[Skip all prompts, accepting default values]"
}
function _lerna_clean {
_arguments -C \
{-y,--yes}"[Skip all confirmation prompts]"
}
function _lerna_exec {
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment