From 1929ae67d71fd0c1971b6c0d99dd101ac8d49461 Mon Sep 17 00:00:00 2001 From: Pavel Morshenyuk Date: Mon, 23 Jul 2018 11:21:23 +0200 Subject: [PATCH] changed theme parameter to be environment variable --- README.md | 11 +++--- assets/{terrain => terran}/jobdelete.mp3 | Bin assets/{terrain => terran}/jobdone.mp3 | Bin assets/{terrain => terran}/jobfail.mp3 | Bin assets/{terrain => terran}/jobinit.mp3 | Bin assets/{terrain => terran}/jobupdate.mp3 | Bin assets/{terrain => terran}/missingargs.mp3 | Bin assets/{terrain => terran}/trapc.mp3 | Bin sceptrefun | 41 +++++++-------------- 9 files changed, 20 insertions(+), 32 deletions(-) rename assets/{terrain => terran}/jobdelete.mp3 (100%) rename assets/{terrain => terran}/jobdone.mp3 (100%) rename assets/{terrain => terran}/jobfail.mp3 (100%) rename assets/{terrain => terran}/jobinit.mp3 (100%) rename assets/{terrain => terran}/jobupdate.mp3 (100%) rename assets/{terrain => terran}/missingargs.mp3 (100%) rename assets/{terrain => terran}/trapc.mp3 (100%) diff --git a/README.md b/README.md index c3a4503..013ab7a 100644 --- a/README.md +++ b/README.md @@ -25,16 +25,17 @@ Run it the same way you would run `sceptre`: sceptrefun $action $env $stack ``` -By default it uses Warcraft sounds, but you can override this behaviour using additional `-t` flag: +By default it uses Warcraft sounds, but you can override this behaviour using `SCEPTRE_THEME` environment variable, just run one of the following commands: -- `-t terran` - for Starcraft Terrain sounds -- `-t protoss` - for Starcraft Protoss sounds -- `-t zerg` - for Starcraft Zerg sounds +- `export SCEPTRE_THEME="terran"` - for Starcraft Terran sounds +- `export SCEPTRE_THEME="protoss"` - for Starcraft Protoss sounds +- `export SCEPTRE_THEME="zerg"` - for Starcraft Zerg sounds Command with override could look like this: ```bash -sceptrefun -t terran launch-stack dev vpc +export SCEPTRE_THEME="terran" +sceptrefun launch-stack dev vpc ``` If you trust this project and want to stop typing `sceptrefun` everytime, put this in your `~/.zshrc` or `~/.bashrc`: diff --git a/assets/terrain/jobdelete.mp3 b/assets/terran/jobdelete.mp3 similarity index 100% rename from assets/terrain/jobdelete.mp3 rename to assets/terran/jobdelete.mp3 diff --git a/assets/terrain/jobdone.mp3 b/assets/terran/jobdone.mp3 similarity index 100% rename from assets/terrain/jobdone.mp3 rename to assets/terran/jobdone.mp3 diff --git a/assets/terrain/jobfail.mp3 b/assets/terran/jobfail.mp3 similarity index 100% rename from assets/terrain/jobfail.mp3 rename to assets/terran/jobfail.mp3 diff --git a/assets/terrain/jobinit.mp3 b/assets/terran/jobinit.mp3 similarity index 100% rename from assets/terrain/jobinit.mp3 rename to assets/terran/jobinit.mp3 diff --git a/assets/terrain/jobupdate.mp3 b/assets/terran/jobupdate.mp3 similarity index 100% rename from assets/terrain/jobupdate.mp3 rename to assets/terran/jobupdate.mp3 diff --git a/assets/terrain/missingargs.mp3 b/assets/terran/missingargs.mp3 similarity index 100% rename from assets/terrain/missingargs.mp3 rename to assets/terran/missingargs.mp3 diff --git a/assets/terrain/trapc.mp3 b/assets/terran/trapc.mp3 similarity index 100% rename from assets/terrain/trapc.mp3 rename to assets/terran/trapc.mp3 diff --git a/sceptrefun b/sceptrefun index a01db50..f936e2b 100755 --- a/sceptrefun +++ b/sceptrefun @@ -15,34 +15,21 @@ SCEPTRE_ACTION=$1 SCEPTRE_ENV=$2 SCEPTRE_STACK=$3 CHANGE_SET=$4 -THEME="orc" - -while getopts "t:" OPTION -do - case $OPTION in - t) - THEME="$OPTARG" - if [ ! -d "$BASEDIR/assets/$THEME" ]; then - echo -e '\033[1;33m'"'$THEME' theme does not exist" '\033[0m' - exit 1 - fi - ARGTOTAL=5 - SCEPTRE_ACTION=$3 - SCEPTRE_ENV=$4 - SCEPTRE_STACK=$5 - CHANGE_SET=$6 - ;; - esac -done - -SCEPTRE_UPGRADE_STACK="$BASEDIR/assets/$THEME/jobupdate.mp3" -SCEPTRE_DELETE_STACK="$BASEDIR/assets/$THEME/jobdelete.mp3" -SCEPTRE_SUCCESS="$BASEDIR/assets/$THEME/jobdone.mp3" -SCEPTRE_FAIL="$BASEDIR/assets/$THEME/jobfail.mp3" -SCEPTRE_INIT="$BASEDIR/assets/$THEME/jobinit.mp3" -MISSINGARGS="$BASEDIR/assets/$THEME/missingargs.mp3" -TRAPC="$BASEDIR/assets/$THEME/trapc.mp3" +SCEPTRE_THEME_DEFAULT="orc" +SCEPTRE_THEME=${SCEPTRE_THEME-$SCEPTRE_THEME_DEFAULT} +if [ ! -d "$BASEDIR/assets/$SCEPTRE_THEME" ]; then + echo -e '\033[1;33m'"'$SCEPTRE_THEME' theme does not exist, will use default '$SCEPTRE_THEME_DEFAULT' theme" '\033[0m' + SCEPTRE_THEME=$SCEPTRE_THEME_DEFAULT +fi + +SCEPTRE_UPGRADE_STACK="$BASEDIR/assets/$SCEPTRE_THEME/jobupdate.mp3" +SCEPTRE_DELETE_STACK="$BASEDIR/assets/$SCEPTRE_THEME/jobdelete.mp3" +SCEPTRE_SUCCESS="$BASEDIR/assets/$SCEPTRE_THEME/jobdone.mp3" +SCEPTRE_FAIL="$BASEDIR/assets/$SCEPTRE_THEME/jobfail.mp3" +SCEPTRE_INIT="$BASEDIR/assets/$SCEPTRE_THEME/jobinit.mp3" +MISSINGARGS="$BASEDIR/assets/$SCEPTRE_THEME/missingargs.mp3" +TRAPC="$BASEDIR/assets/$SCEPTRE_THEME/trapc.mp3" trap trapctrlc SIGINT trapctrlc() {