Skip to content

Commit

Permalink
named args
Browse files Browse the repository at this point in the history
  • Loading branch information
fgimenez committed Mar 10, 2024
1 parent 327a843 commit f10322f
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 13 deletions.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ runs:
using: 'docker'
image: 'Dockerfile'
args:
- --foundry-command
- ${{ inputs.foundry-command }}
- --foundry-directory
- ${{ inputs.foundry-directory }}
- --foundry-script
- ${{ inputs.foundry-script }}
39 changes: 26 additions & 13 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
#!/bin/bash

FOUNDRY_COMMAND="$1"
SOLC_PATH="--use /usr/local/bin/solc"
FOUNDRY_DIRECTORY="--root $2"
FOUNDRY_SCRIPT="$3"
main() {
local FOUNDRY_COMMAND=""
local FOUNDRY_DIRECTORY=""
local FOUNDRY_SCRIPT=""
local SOLC_PATH="--use /usr/local/bin/solc"

if [ "$FOUNDRY_COMMAND" = "script" ] && [ -z "$FOUNDRY_SCRIPT" ]; then
echo "Error: 'foundry-script' is required when 'foundry-command' is 'script'"
exit 1
fi
# Parse named arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--foundry-command) FOUNDRY_COMMAND="$2"; shift ;;
--foundry-directory) FOUNDRY_DIRECTORY="--root $2"; shift ;;
--foundry-script) FOUNDRY_SCRIPT="$2"; shift ;;
*) echo "Unknown parameter passed: $1"; exit 1 ;;
esac
shift
done

if [ "$FOUNDRY_COMMAND" = "script" ]; then
exec forge script $FOUNDRY_SCRIPT $SOLC_PATH $FOUNDRY_DIRECTORY --fork-url http://localhost:8545 --broadcast -vvvv
else
exec forge $FOUNDRY_COMMAND $SOLC_PATH $FOUNDRY_DIRECTORY
fi
if [ "$FOUNDRY_COMMAND" = "script" ] && [ -z "$FOUNDRY_SCRIPT" ]; then
echo "Error: 'foundry-script' is required when 'foundry-command' is 'script'"
exit 1
fi

if [ "$FOUNDRY_COMMAND" = "script" ]; then
exec forge script $FOUNDRY_SCRIPT $SOLC_PATH $FOUNDRY_DIRECTORY --fork-url http://localhost:8545 --broadcast -vvvv
else
exec forge $FOUNDRY_COMMAND $SOLC_PATH $FOUNDRY_DIRECTORY
fi
}

0 comments on commit f10322f

Please sign in to comment.