-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow arguments and options to be passed through to workflow scripts (#…
…24) ### Main Changes Allow arguments and options to be passed through to underlying workflow commands, e.g. ```bash composer -- pup workflow set-version -- arg1 arg2 otherArg --option-one=test1 --option-two=test2 ``` ![image](https://github.com/user-attachments/assets/2c923671-3e4e-4b81-8e8a-f09c2dec8a7d)
- Loading branch information
Showing
6 changed files
with
138 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/usr/bin/env bash | ||
|
||
# A test workflow run via the test suite | ||
|
||
# Loop through all the arguments | ||
while [[ "$#" -gt 0 ]]; do | ||
case $1 in | ||
--*=*) # Option in --option=value format | ||
option="${1%%=*}" # Extract the option | ||
value="${1#*=}" # Extract the value | ||
echo "Option: $option, Value: $value" | ||
shift | ||
;; | ||
--*) # Option in --option format (expecting a separate value) | ||
option=$1 | ||
shift | ||
if [[ "$1" && ! "$1" =~ ^-- ]]; then | ||
value=$1 | ||
echo "Option: $option, Value: $value" | ||
shift | ||
else | ||
echo "Option: $option, No value provided" | ||
fi | ||
;; | ||
*) # Regular argument | ||
echo "Argument: $1" | ||
shift | ||
;; | ||
esac | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...wCest__it_should_pass_additional_arguments_and_options_to_workflow_script__0.snapshot.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Running test-workflow workflow steps... | ||
|
||
> /var/www/html/wp-content/plugins/pup/tests/_data/test-workflow-script.sh 'arg1' 'arg2' '--option-one=one' '--option-two=two' | ||
------------------------------------------------------------------------------------------------------------------------------ | ||
|
||
Argument: arg1 | ||
Argument: arg2 | ||
Option: --option-one, Value: one | ||
Option: --option-two, Value: two | ||
|
||
Workflow complete. |