libexec/build in alpha_omega-1.0.1 vs libexec/build in alpha_omega-1.1.1

- old
+ new

@@ -1,199 +1,30 @@ -#!/bin/bash -e +#!/bin/bash -export LOCAL_ONLY= +#/ NAME +#/ build-gem -- upload the latest (timestamp) rubygem to rubygems.org +#/ +#/ SYNOPSIS +#/ build gem -n gem_name -case "$(basename $0)" in - invoke) - export COMMAND="$1"; shift +# figure out the project root under which bin, lib live +shome="$(cd -P -- "$(dirname -- "$BASH_SOURCE")/.." && pwd -P)" - if [[ -n $1 ]]; then - set -- $(for a in "$@"; do echo $a.app; done) - fi +# load a jason bourne library +source "$shome/bin/_treadstone" - tmp_invoke=$(mktemp -t XXXXXXXXX) - bundle exec cap "$@" invoke 2>&1 | perl -pe 's{.\[\d+m}{}g' | perl -ne 'm{^\s*\*+\s*\[(out|err)\s*::\s*([^]]+)\] ?(.*)} && print "$1 $2 $3\n"' > $tmp_invoke 2>&1 +# define command line options: +DEFINE_string 'name' "$(basename "$shome")" 'name of gem' 'n' - cat $tmp_invoke | awk '{print $2}' | sort -u | while read -r nm_host; do - egrep "^(out|err) $nm_host" $tmp_invoke || true - echo - done - rm -f $tmp_invoke - ;; - *) - if [[ -n $1 ]]; then - set -- $(for a in "$@"; do echo $a; done) - fi +# entry point +function main { + local pth_gemspec="$shome/$FLAGS_name.gemspec" + if [[ ! -e "$pth_gemspec" ]]; then + logger_fatal "could not find gemspec $pth_gemspec" + exit 1 + fi - case "$(basename $0)" in - debug) - LOCAL_ONLY=true - if [[ -z $1 ]]; then - set "world" - fi + cd "$shome" + gem build "$pth_gemspec" +} - if [[ -n $1 ]]; then - cap $(for a in "$@"; do echo $a.echo; done) - fi - ;; - - hosts) - LOCAL_ONLY=true - { - if [[ -n $1 ]]; then - cap $(for a in "$@"; do echo $a.echo; done) - fi - } 2>&1 | grep eea914aaa8dde6fdae29242b1084a2b0415eefaf | awk '{print $NF}' | sort -u - ;; - - dna) - LOCAL_ONLY=true - { - echo "eea914aaa8dde6fdae29242b1084a2b0415eefaf ---" - if [[ -n $1 ]]; then - cap $(for a in "$@"; do echo $a.yaml; done) - fi - } 2>&1 | grep eea914aaa8dde6fdae29242b1084a2b0415eefaf | sed 's#eea914aaa8dde6fdae29242b1084a2b0415eefaf ##' - ;; - - task) - if [[ -n $1 ]]; then - nm_task=$1; shift - set -- $(for a in "$@"; do echo $a.app; done) - fi - bundle exec cap "$@" deploy:lock_migrate deploy:migrate "$nm_task" - ;; - - *) - if [[ -n $1 ]]; then - set -- $(for a in "$@"; do echo $a.app; done) - fi - case "$(basename $0)" in - deploy) - bundle exec cap "$@" deploy:lock deploy - ;; - - release) - bundle exec cap "$@" deploy:lock deploy - ;; - - stage) - bundle exec cap "$@" deploy:lock deploy:update_code deploy:symlink_next - ;; - - restart) - bundle exec cap "$@" deploy:lock deploy:restart - ;; - - config) - bundle exec cap "$@" deploy:lock deploy:config - ;; - - build) - bundle exec cap "$@" deploy:lock deploy:build - ;; - - dist) - bundle exec cap "$@" deploy:lock deploy:dist - ;; - - activate) - bundle exec cap "$@" deploy:lock deploy:symlink deploy:restart - ;; - - rollback) - bundle exec cap "$@" deploy:lock deploy:rollback - ;; - - check) - bundle exec cap "$@" deploy:lock deploy:check - ;; - - plan) - bundle exec cap "$@" deploy:lock deploy:plan - ;; - - lock) - case "${1%.app}" in - compare|migrate) - nm_lock="${1%.app}"; shift - bundle exec cap "$@" deploy:dont_unlock "deploy:lock_${nm_lock}" - ;; - *) - bundle exec cap "$@" deploy:dont_unlock deploy:lock - ;; - esac - ;; - - unlock) - case "${1%.app}" in - compare|migrate) - nm_lock="${1%.app}"; shift - bundle exec cap "$@" "deploy:unlock_${nm_lock}" - ;; - *) - bundle exec cap "$@" deploy:unlock - ;; - esac - ;; - - shell) - bundle exec cap "$@" shell - ;; - - compare) - bundle exec cap "$@" deploy:lock_compare deploy:compare - ;; - - repl) - bundle exec cap "$@" deploy:lock_compare deploy:repl - ;; - - migrate) - want_list= - if [[ "${1%.app}" = "list" ]]; then - want_list=1; shift - fi - - change_group= - migration= - case "${1%.app}" in - data) - change_group=${1%.app}; shift - ;; - pre) - change_group=${1%.app}; shift - ;; - during) - change_group=${1%.app} shift - ;; - post) - change_group=${1%.app}; shift - ;; - [0123456789][0123456789][0123456789][0123456789][0123456789][0123456789][0123456789][0123456789][0123456789][0123456789][0123456789][0123456789][0123456789][0123456789]) - migration=${1%.app}; shift - ;; - esac - - if [[ -n $change_group ]]; then - if [[ -n $want_list ]]; then - echo "listing change group $change_group" - else - echo "running change group $change_group" - fi - elif [[ -n $migration ]]; then - echo "running migration $migratio" - elif [[ -n $want_list ]]; then - echo "listing migrations" - fi - - bundle exec cap "$@" deploy:lock_migrate deploy:migrate - ;; - - *) - bundle exec cap "$@" - ;; - esac - esac - ;; -esac - +require sub "$BASH_SOURCE" "$@"