Skip to content

Commit

Permalink
add version support
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Flamm committed Jul 20, 2017
1 parent 9b0aa88 commit a6b1f08
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ before_install:
- rvm install 1.9.3
- gem install --no-ri --no-rdoc fpm
script:
- sed -i "s/VERSION_PLACEHOLDER/${TRAVIS_TAG}/g" afpre
- fpm -v ${TRAVIS_TAG} -n afpre -a all -t deb -d jq -d bash -d openssl -d curl --description "CLI for the AWS Federation Proxy" --url "https://github.com/leflamm/afpre" --license "Apache License 2.0" -s dir afpre=/usr/bin/afpre
- fpm -v ${TRAVIS_TAG} -n afpre -a all -t rpm -d jq -d bash -d openssl -d curl -d which --description "CLI for the AWS Federation Proxy" --url "https://github.com/leflamm/afpre" --license "Apache License 2.0" -s dir afpre=/usr/bin/afpre
deploy:
Expand Down
8 changes: 8 additions & 0 deletions afpre
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/bin/bash
VERSION=VERSION_PLACEHOLDER

set -e

Expand Down Expand Up @@ -41,6 +42,11 @@ options_contain() {
grep -q -- "${1}" <<< "${@:2}"
}

do_version() {
echo $VERSION
exit 0
}

do_help() {
! read -d '' HELP <<EOF
usage: ${0} [OPTIONS]
Expand All @@ -51,6 +57,7 @@ OPTIONS
any definition in ${CFG}
--example-cfg ... create an example config file at ${CFG}
--debug ... enable debugging
--version ... print version
EOF
echo "${HELP}"
exit 0
Expand Down Expand Up @@ -82,6 +89,7 @@ longoption_value() {
DEBUG=false

options_contain '--help' "$@" && do_help
options_contain '--version' "$@" && do_version
options_contain '--account' "$@" && ADHOC_ACCOUNT=$(longoption_value account "${@}")
options_contain '--example-cfg' "$@" && do_example_cfg
options_contain '--debug' "$@" && DEBUG=true
Expand Down

0 comments on commit a6b1f08

Please sign in to comment.