Conditional Commands
As of 0.9.10 Enkaidu supports conditional continuation commands that start with a ?.
Conditional commands are intended for use within macros since they allow a macro to exit pre-maturely based on conditions.
Macros are sequences of queries that were executed in order, and nested calls to macros were inserted at the call site and then executed in sequence. Until now we did not have a way for a macro to ask a model to do some work and then test for that.
Using the new ?break with if... or unless... conditional commands macros can now make branching decisions, allowing them to exit a macro earlier in its query sequence.
As of 0.9.11, conditional commands are also used to exit blocks — nested groups of queries within a macro, started with the <enter> key (see Macros). A ?break line inside a block exits that block early, skipping any remaining nested queries, while execution continues with the query following the block.
-
Break on condition
?break if file_exists=<PATH>- Exit macro if given file exists
?break if file=<PATH> contains=<STR>- Exit macro if given file exists and contains given string
?break if global ns=<NAMESPACE> key=<STR> equals=<STR>- Exit macro if global state key has matching value
?break unless file_exists=<PATH>- Exit macro unless given file exists
?break unless file=<PATH> contains=<STR>- Exit macro unless given file exists and contains given string
?break unless global ns=<NAMESPACE> key=<STR> equals=<STR>- Exit macro unless global state key has matching value