diff --git a/libexec/plenv-install-cpm b/libexec/plenv-install-cpm new file mode 100755 index 0000000..1d82196 --- /dev/null +++ b/libexec/plenv-install-cpm @@ -0,0 +1,66 @@ +#!/usr/bin/env bash +# +# Summary: Install cpm +# +# Usage: plenv install-cpm +# +# Install cpm to current perl version +# +set -e +[ -n "$PLENV_DEBUG" ] && set -x + +if [ -z "$PLENV_ROOT" ]; then + PLENV_ROOT="${HOME}/.plenv" +fi + +function parse_options () +{ + OPTIONS=(); + ARGUMENTS=(); + local arg option index; + for arg in "$@"; + do + if [ "${arg:0:1}" = "-" ]; then + if [ "${arg:1:1}" = "-" ]; then + OPTIONS[${#OPTIONS[*]}]="${arg:2}"; + else + index=1; + while option="${arg:$index:1}"; do + [ -n "$option" ] || break; + OPTIONS[${#OPTIONS[*]}]="$option"; + index=$(($index+1)); + done; + fi; + else + ARGUMENTS[${#ARGUMENTS[*]}]="$arg"; + fi; + done +}; + +usage() { + # We can remove the sed fallback once plenv 0.4.0 is widely available. + plenv-help install-cpm 2>/dev/null || sed -ne '/^#/!q;s/.//;s/.//;1,4d;p' < "$0" + [ -z "$1" ] || exit "$1" +} + +unset VERBOSE + +# CURRENT=$(cd $(dirname $0) && pwd) +# PERL_BUILD=$CURRENT/perl-build + +# exec $PERL_BUILD $* +parse_options "$@" +for option in "${OPTIONS[@]}"; do + case "$option" in + "h" | "help" ) + usage 0 + ;; + * ) + usage 1 + ;; + esac +done + +PLENV_INSTALL_CPANM=${PLENV_INSTALL_CPANM:--p} +curl ${PLENV_INSTALL_CPANM} -L http://git.io/cpm | plenv exec perl - install -g App::cpm +plenv rehash diff --git a/plenv.d/rehash/rehash_cpm.bash b/plenv.d/rehash/rehash_cpm.bash new file mode 100755 index 0000000..bbfc889 --- /dev/null +++ b/plenv.d/rehash/rehash_cpm.bash @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -e + +CPM_SHIM_PATH="$SHIM_PATH/cpm" + +command -p cat > "$CPM_SHIM_PATH" <