Skip to content

Commit

Permalink
changing how to check for cf-cli
Browse files Browse the repository at this point in the history
  • Loading branch information
mpivotal committed Apr 5, 2016
1 parent 183335b commit 8982df2
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cfswitch
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,21 @@

usage="Usage: cfswitch <CF ACCOUNT>"

if type cf > /dev/null ; then # do we have the cf CLI installed?
if [ `command -v cf` ] ; then # do we have the cf CLI installed?

if [ $1 ]; then # did we provide the account option?
if [ $1 ] ; then # did we provide the account option?

account=`tput bold`$1`tput sgr0` # set our account variable with fancy bold formatting

if [ `ls ~/.cf/config.json.$1 2> /dev/null` ]; then # does that account config exist?
if [ `ls ~/.cf/config.json.$1 2> /dev/null` ] ; then # does that account config exist?


echo ""
echo "Switching to $account cf account..."
cp ~/.cf/config.json.$1 ~/.cf/config.json
cf target
exit 0

else # nope, that account config doesn't exist.
echo "Whoa there!"
echo "You have not created ~/.cf/config.json.$account"
Expand Down Expand Up @@ -47,4 +50,3 @@ else # nope, the cf CLI isn't installed.
echo "Download the cf CLI https://github.com/cloudfoundry/cli/blob/master/README.md#downloads"
exit 1
fi

0 comments on commit 8982df2

Please sign in to comment.