Skip to content

Commit

Permalink
Move '--config-file' out of the args-parsing loop.
Browse files Browse the repository at this point in the history
This should allow a config. file specified on the command-line to
overwrite values set in '.env', which in turn ovewrite values set
in the environment. Values set for these same vars in the args-
parsing loop should then overwrite all of the above.

Anything left unset by environment vars above are then covered when
the "internal" vars are populated by the `var=${ENV_VAR:-default}`
lines.
  • Loading branch information
Matt Pearson committed Dec 12, 2015
1 parent 676d33f commit 3994857
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ main() {
source .env
fi

# Set args from file specified on the command-line.
if [[ $1 = "-c" || $1 = "--config-file" ]]; then

This comment has been minimized.

Copy link
@X1011

X1011 Dec 16, 2015

this is only going to work now if it's the 1st argument, which i'm ok with if we want to avoid more complexity, since i think this will be a niche feature, but if so, we should mention it in the documentation to avoid confusion.

This comment has been minimized.

Copy link
@matro

matro Dec 16, 2015

Owner

Yeah. I feel like it's less than ideal, but I haven't figured out a way to do this in a way where position doesn't matter yet. I've added docs for this in f1b23e1. Hopefully X1011#20 will get the positional stuff figured out and we can remove this little quirk.

source "$2"
shift 2
fi

# Parse arg flags
# If something is exposed as an environment variable, set/overwrite it
# here. Otherwise, set/overwrite the internal variable instead.
Expand All @@ -23,9 +29,6 @@ main() {
elif [[ $1 = "-n" || $1 = "--no-hash" ]]; then
GIT_DEPLOY_APPEND_HASH=false
shift
elif [[ $1 = "-c" || $1 = "--config-file" ]]; then
source "$2"
shift 2
else
break
fi
Expand Down

0 comments on commit 3994857

Please sign in to comment.