Skip to content

Commit

Permalink
feat(shirelang): add support for finish flags in output control flow #24
Browse files Browse the repository at this point in the history


- Added support for defining finish flags in the output control flow to control the flow based on specific conditions.
  • Loading branch information
phodal committed Jun 25, 2024
1 parent dd4c8f9 commit 99f1023
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
6 changes: 4 additions & 2 deletions docs/shire/output-control-flow.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,7 @@ nav_order: 8

Output Control Flow 用于定义输出的控制流,支持以下几种控制流:

- `if`:条件判断。
- `case`:多条件判断。
元素:

- onFlag:
- onCondition:
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,3 @@ class ShireParsingTest : ParsingTestCase("parser", "shire", ShireParserDefinitio
doTest(true)
}
}

23 changes: 20 additions & 3 deletions shirelang/src/test/testData/realworld/LifeCycle.shire
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
---
onProcessing: [""]
onResponseFinish: ["VerifyCode", "RunCode"]
afterFinish: OpenFile
menuActivate: "xxx"
onStreamStart: [""]
onStreamFinish: ["VerifyCode", "RunCode"]
finishFlag: {
flags: {
"variable-sucesss": $selection.length > 1
"jsonpath-success": jsonpath("$.phoneNumbers[:1].type")
"fail": '$content.contains("error") && $content.regex("exception")'
}
case flags {
"variable-sucesss" { done }
"jsonpath-success" { task() }
"fail" { task() }
}
}
---

afterStreamFinish:

- //bookstore/book[price>35]
- $.phoneNumbers[:1].type
- Regex

0 comments on commit 99f1023

Please sign in to comment.