|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +__SOURCE__="${BASH_SOURCE[0]}" |
| 4 | +while [[ -h "${__SOURCE__}" ]]; do |
| 5 | + __SOURCE__="$(find "${__SOURCE__}" -type l -ls | sed -n 's@^.* -> \(.*\)@\1@p')" |
| 6 | +done |
| 7 | +__DIR__="$(cd -P "$(dirname "${__SOURCE__}")" && pwd)" |
| 8 | +__NAME__="${__SOURCE__##*/}" |
| 9 | +__AUTHOR__='S0AndS0' |
| 10 | +__DESCRIPTION__='Upgrades bundler for account via: gem bundle install' |
| 11 | + |
| 12 | + |
| 13 | +## Provides 'failure' |
| 14 | +source "${__DIR__}/shared_functions/modules/trap-failure/failure.sh" |
| 15 | +trap 'failure "LINENO" "BASH_LINENO" "${BASH_COMMAND}" "${?}"' ERR |
| 16 | + |
| 17 | +## Provides: argument_parser <arg-array-reference> <acceptable-arg-reference> |
| 18 | +source "${__DIR__}/shared_functions/modules/argument-parser/argument-parser.sh" |
| 19 | + |
| 20 | +## Provides: __license__ <description> <author> |
| 21 | +source "${__DIR__}/shared_functions/license" |
| 22 | + |
| 23 | + |
| 24 | +usage(){ |
| 25 | + _message="${1}" |
| 26 | + _repo_name="${_repo_name:-repository-name}" |
| 27 | + cat <<EOF |
| 28 | +## Usage |
| 29 | +# ssh ${USER}@host-or-ip ${__NAME__} ${_repo_name} |
| 30 | +# |
| 31 | +# ${__DESCRIPTION__} |
| 32 | +# |
| 33 | +# -l --license |
| 34 | +# Shows script or project license then exits |
| 35 | +# |
| 36 | +# -v --verbose |
| 37 | +# Runs build commands verbosely |
| 38 | +# |
| 39 | +# -h --help help |
| 40 | +# Displays this message and exits |
| 41 | +EOF |
| 42 | + (("${#_message}")) && [[ "${_message}" != '0' ]] && { |
| 43 | + printf >&2 'Error - %s\n' "${_message}" |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | + |
| 48 | +_args=("${@:?# No arguments provided try: ${__NAME__} help}") |
| 49 | +_valid_args=('--help|-h|help:bool' |
| 50 | + '--verbose|-v|verbose:bool' |
| 51 | + '--license|-l|license:bool') |
| 52 | +argument_parser '_args' '_valid_args' |
| 53 | +_exit_status="$?" |
| 54 | + |
| 55 | + |
| 56 | +if ((_help)) || ((_exit_status)); then |
| 57 | + usage "${_exit_status}" |
| 58 | + exit "${_exit_status}" |
| 59 | +elif ((_license)); then |
| 60 | + __license__ "${__DESCRIPTION__}" "${__AUTHOR__}" |
| 61 | + exit 0 |
| 62 | +fi |
| 63 | + |
| 64 | + |
| 65 | +gem install bundler |
0 commit comments