Skip to content

task

Tasks are defined using code blocks in your markdown file (default: spryfile.md).

Execute specific tasks and their dependencies.

Terminal window
./spry.ts task <taskId> [options]
  • --summarize - Emit execution summary in JSON format
Terminal window
# 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 rich

To add description in the above task

Terminal window
```bash
task-name --descr "Add description sentence here"
```

When you list tasks, the description will appear alongside the task name.

To add dependencies to a task

Terminal window
```bash
new-task-name --dep old-task-name
```
  • Here, new-task-name refers to the new task being added, and old-task-name refers 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.

Terminal window
```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-depsbuilddeploy

Terminal window
./spry.ts task ls

Lists all executable task cells in the default spryfile.md.

Terminal window
./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, Spry only considers spryfile.md.
Terminal window
./spry.ts task ls --all

Lists all cells, not just executable ones.

Terminal window
./spry.ts task ls --select "language:bash"

Use CQL to filter cells based on various criteria. See CQL documentation for advanced queries.

Control the amount of output displayed during task execution.

Terminal window
./spry.ts task <task-name> --verbose <format>
  • plain - Simple text output
  • rich - Enhanced output with formatting and colors
  • markdown - Output formatted as markdown

Example:

Terminal window
./spry.ts task build --verbose rich

Run ./spry.ts task --help to see all available options.

Organize tasks into groups using custom flags for selective execution.

Terminal window
```bash
setup-db --graph init --descr "Initialize database"
./scripts/init-db.sh
```
```bash
seed-db --graph init --descr "Seed database with data"
./scripts/seed-db.sh
```
```bash
deploy-app --graph deploy --descr "Deploy application"
./scripts/deploy.sh
```
Terminal window
./spry.ts task ls --select 'flags.graph == "init"'
Terminal window
./spry.ts runbook --select 'flags.graph == "init"'

This executes only the tasks tagged with --graph init.

You can use any custom tag name instead of --graph:

Terminal window
```bash
task-name --environment production --descr "Production task"
echo "Running in production"
```

Filter and execute:

Terminal window
./spry.ts runbook --select 'flags.environment == "production"'

For more details on CQL queries, refer to the CQL documentation.


Capture task output to files in various formats.

Terminal window
```bash
taskname -C ./output.json --descr "Task with output capture"
echo '{"status": "success"}'
```

Supported formats: JSON, CSV, XML

  • -C ./file.* - Saves the output to the specified file
  • -C file.* - Marks the task as capturable without saving immediately
  • --capture - Long form of the -C flag

When listing tasks with ./spry.ts task ls, tasks with capture enabled will display the C flag in the “Flag” column.

Example:

Terminal window
./spry.ts task ls

Output:

Task ID | Flag | Description
------------- | ---- | -----------
fetch-data | C | Fetch data from API
process-data | | Process fetched data

Visualize the task dependency graph to understand execution flow and dependencies.

Terminal window
./spry.ts runbook --visualize <style>
  • ascii-tree - Tree-style ASCII representation
  • ascii-workflow - Workflow-style ASCII diagram
  • ascii-flowchart - Flowchart-style ASCII diagram
  • mermaid-js - Mermaid.js format (can be rendered in markdown viewers)

Example:

Terminal window
./spry.ts runbook --visualize ascii-tree

This helps you understand the Directed Acyclic Graph (DAG) of tasks and their execution order.


Execute all declared tasks in your markdown file.

Terminal window
./spry.ts runbook

This command runs all tasks defined in spryfile.md in their dependency order.

Terminal window
./spry.ts runbook --md example.md

Combine with CQL to run specific subsets:

Terminal window
./spry.ts runbook --select 'flags.graph == "test"'