The Command (jq)
Encapsulate operations as discrete JSON objects for deferred execution.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Command
ARCANUM SCHOOL: Enchantment // Binding
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
# Command definitions
# { "cmd": "add", "args": [10, 20] }
# The Invoker
def execute_command:
if .cmd == "add" then
.args[0] + .args[1]
elif .cmd == "concat" then
.args | join("")
else
"Unknown Command"
end;
# Processing the macro sequence
.macro_sequence[] | execute_command
By capturing an action and its parameters within a hardened JSON shell, the Command pattern converts behavior into data. These command packets can be queued, logged, or reversed before they are eventually fed into the Invoker filter. It is the ultimate decoupling of intention and execution in the datascape.
Runic Tags:
#jq
#json
#transmutation
#gof