task
Defining Tasks
Section titled “Defining Tasks”Tasks are defined using code blocks in your markdown file (default: spryfile.md).
task - Task Execution
Section titled “task - Task Execution”Execute specific tasks and their dependencies.
./spry.ts task <taskId> [options]Options
Section titled “Options”--summarize- Emit execution summary in JSON format
Examples
Section titled “Examples”# Execute a specific task./spry.ts task prepare-db
# Execute a task and all its dependencies./spry.ts task setup-db
# Execute with summary./spry.ts task deploy --summarize --verbose richAdd Task Description
Section titled “Add Task Description”To add description in the above task
```bashtask-name --descr "Add description sentence here"```When you list tasks, the description will appear alongside the task name.
Add dependencies to a task
Section titled “Add dependencies to a task”To add dependencies to a task
```bashnew-task-name --dep old-task-name```- Here,
new-task-namerefers to the new task being added, andold-task-namerefers to a pre-existing task already defined in the markdown file.
The --dep flag ensures that old-task-name executes before new-task-name. You can specify multiple dependencies.
Try It Out
Section titled “Try It Out”```bash install-deps --descr "Install project dependencies"npm install```
```bash build --dep install-deps --descr "Build the project"npm run build```
```bash deploy --dep build --descr "Deploy to production"./deploy.sh```Running ./spry.ts task deploy will execute: install-deps → build → deploy
Listing Tasks
Section titled “Listing Tasks”List Executable Tasks
Section titled “List Executable Tasks”./spry.ts task lsLists all executable task cells in the default spryfile.md.
List from Custom Markdown File
Section titled “List from Custom Markdown File”./spry.ts task ls --md example.md- If you are using a custom markdown file (other than
spryfile.md), you need to specify it as shown in the command above, because by default,Spryonly considersspryfile.md.
List All Cells
Section titled “List All Cells”./spry.ts task ls --allLists all cells, not just executable ones.
Filter with Cell Query Language (CQL)
Section titled “Filter with Cell Query Language (CQL)”./spry.ts task ls --select "language:bash"Use CQL to filter cells based on various criteria. See CQL documentation for advanced queries.
Output Verbosity
Section titled “Output Verbosity”Control the amount of output displayed during task execution.
./spry.ts task <task-name> --verbose <format>Verbosity Formats
Section titled “Verbosity Formats”plain- Simple text outputrich- Enhanced output with formatting and colorsmarkdown- Output formatted as markdown
Example:
./spry.ts task build --verbose richRun ./spry.ts task --help to see all available options.
Task Graphs and Filtering
Section titled “Task Graphs and Filtering”Organize tasks into groups using custom flags for selective execution.
Define Tasks with Graph Tags
Section titled “Define Tasks with Graph Tags”```bashsetup-db --graph init --descr "Initialize database"./scripts/init-db.sh``````bashseed-db --graph init --descr "Seed database with data"./scripts/seed-db.sh``````bashdeploy-app --graph deploy --descr "Deploy application"./scripts/deploy.sh```List Tasks by Graph Tag
Section titled “List Tasks by Graph Tag”./spry.ts task ls --select 'flags.graph == "init"'Execute Tasks by Graph Tag
Section titled “Execute Tasks by Graph Tag”./spry.ts runbook --select 'flags.graph == "init"'This executes only the tasks tagged with --graph init.
Custom Tags
Section titled “Custom Tags”You can use any custom tag name instead of --graph:
```bashtask-name --environment production --descr "Production task"echo "Running in production"```Filter and execute:
./spry.ts runbook --select 'flags.environment == "production"'For more details on CQL queries, refer to the CQL documentation.
Output Capture
Section titled “Output Capture”Capture task output to files in various formats.
Save Output to File
Section titled “Save Output to File”```bashtaskname -C ./output.json --descr "Task with output capture"echo '{"status": "success"}'```Supported formats: JSON, CSV, XML
Capture Flags
Section titled “Capture Flags”-C ./file.*- Saves the output to the specified file-C file.*- Marks the task as capturable without saving immediately--capture- Long form of the-Cflag
Viewing Capturable Tasks
Section titled “Viewing Capturable Tasks”When listing tasks with ./spry.ts task ls, tasks with capture enabled will display the C flag in the “Flag” column.
Example:
./spry.ts task lsOutput:
Task ID | Flag | Description------------- | ---- | -----------fetch-data | C | Fetch data from APIprocess-data | | Process fetched dataVisualization
Section titled “Visualization”Visualize the task dependency graph to understand execution flow and dependencies.
./spry.ts runbook --visualize <style>Supported Styles
Section titled “Supported Styles”ascii-tree- Tree-style ASCII representationascii-workflow- Workflow-style ASCII diagramascii-flowchart- Flowchart-style ASCII diagrammermaid-js- Mermaid.js format (can be rendered in markdown viewers)
Example:
./spry.ts runbook --visualize ascii-treeThis helps you understand the Directed Acyclic Graph (DAG) of tasks and their execution order.
Running All Tasks
Section titled “Running All Tasks”Execute all declared tasks in your markdown file.
./spry.ts runbookThis command runs all tasks defined in spryfile.md in their dependency order.
Run All Tasks from Custom File
Section titled “Run All Tasks from Custom File”./spry.ts runbook --md example.mdRun with Filters
Section titled “Run with Filters”Combine with CQL to run specific subsets:
./spry.ts runbook --select 'flags.graph == "test"'