Last active
January 3, 2023 13:59
-
-
Save flisboac/569acddb9ac0a2b19d46c7c4aa5e739b to your computer and use it in GitHub Desktop.
simple state function to perform join with json serialization
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
{ | |
"StartAt": "CreateCliParams", | |
"States": { | |
"CreateCliParams": { | |
"Type": "Pass", | |
"Next": "CreateCliParams_ifJoinParams", | |
"Parameters": { | |
"CliParameterSeparator.$": "$.CliParameterSeparator", | |
"CliCurrentParameterSeparator": "", | |
"CliParameters.$": "$.CliParameters[*][*]", | |
"CliParametersBuffer": "", | |
"CliParameterIndex.$": "States.ArrayLength($.CliParameters[*][*])" | |
} | |
}, | |
"CreateCliParams_ifJoinParams": { | |
"Type": "Choice", | |
"Choices": [ | |
{ | |
"Variable": "$.CliParameterIndex", | |
"NumericGreaterThan": 0, | |
"Next": "CreateCliParams_thenJoinParams" | |
} | |
], | |
"Default": "ExecuteCliCommand" | |
}, | |
"CreateCliParams_thenJoinParams": { | |
"Type": "Pass", | |
"Next": "CreateCliParams_ifJoinParams", | |
"Parameters": { | |
"CliParameterSeparator.$": "$.CliParameterSeparator", | |
"CliCurrentParameterSeparator.$": "$.CliParameterSeparator", | |
"CliParameters.$": "$.CliParameters[1:]", | |
"CliParametersBuffer.$": "States.Format('{}{}{}', $.CliParametersBuffer, $.CliCurrentParameterSeparator, States.JsonToString($.CliParameters[0]))", | |
"CliParameterIndex.$": "States.MathAdd($.CliParameterIndex, -1)" | |
} | |
}, | |
"ExecuteCliCommand": { | |
"Type": "Pass", | |
"Next": "End", | |
"Parameters": { | |
"CliCommand.$": "States.Format('bash -c {}', States.JsonToString($.CliParametersBuffer))" | |
} | |
}, | |
"End": { | |
"Type": "Succeed" | |
} | |
} | |
} |
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
{ | |
"CliParameters": [["ls"], ["-la", "-w", 1], ["\".\""]], | |
"CliParameterSeparator": " " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment