Skip to content

Commit

Permalink
fix: command line generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Bastien Gatellier committed Oct 25, 2023
1 parent 32791b7 commit 8714487
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@

# generate_heart_command analysisService config threshold except-listeners only-listeners verbose
# Generate the heart command from the given arguments.
generate_heart_command() {
local cliOptions=" --config $2"
function generate_heart_command {
local cliOptions=" --config $1"

if [ -n "$3" ]; then cliOptions+=" --threshold $3"; fi
if [ -n "$4" ]; then cliOptions+=" --except-listeners $4"; fi
if [ -n "$5" ]; then cliOptions+=" --only-listeners $5"; fi
if [ -n "$6" ]; then cliOptions+=" --verbose"; fi
if [ -n "$2" ]; then cliOptions+=" --threshold $2"; fi
if [ -n "$3" ]; then cliOptions+=" --except-listeners $3"; fi
if [ -n "$4" ]; then cliOptions+=" --only-listeners $4"; fi
if [ -n "$5" ]; then cliOptions+=" --verbose"; fi

echo $1$cliOptions
}

# trim(string)
# Trim a string.
# see https://stackoverflow.com/a/3232433
trim() {
function trim {
echo "$(echo -e "${1}" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
}

Expand All @@ -31,6 +31,7 @@ exceptServices=$(trim $4)
onlyServices=$(trim $5)
verbose=$(trim $6)

echo "$GITHUB_WORKSPACE/$config"
if [[ -f "$GITHUB_WORKSPACE/$config" ]]; then
config="$GITHUB_WORKSPACE/$config"
fi
Expand Down

0 comments on commit 8714487

Please sign in to comment.