Automate Your Workflow with ShellRun — Beginner to Pro

Getting Started with ShellRun: Tips, Tricks, and Shortcuts

What ShellRun is

ShellRun is a command-line utility (assumed here as a shell task runner) that executes scripts, commands, and automated workflows from a single interface. It typically supports task definitions, argument passing, environment variables, and chaining or scheduling of commands.

Quick setup

  1. Install: Use the package manager for your environment (example):

    bash

    # macOS / Linux (example) curl -sSL https://example.com/shellrun/install.sh | bash
  2. Init a project:

    bash

    shellrun init
  3. Create tasks: Add a tasks file (e.g., ShellRunfile or shellrun.yml) with entries mapping names to commands.

Essential commands

  • Run a task: shellrun run
  • List tasks: shellrun list
  • Run with env file: SHELLRUN_ENV=.env shellrun run build
  • Dry-run: shellrun run –dry (shows commands without executing)
  • Verbose: shellrun run -v (prints expanded commands and environment)

Recommended task file structure (example)

yaml

# shellrun.yml tasks: build: cmd: npm run build env: NODE_ENV: production test: cmd: npm test deploy: cmd: ./scripts/deploy.sh deps: - build - test

Useful tips

  • Use dependencies: Define deps so build/test run automatically before deploy.
  • Parametrize tasks: Accept positional arguments or flags to reuse tasks for different environments (e.g., shellrun run deploy – env=staging).
  • Secrets management: Load secrets from a protected .env file and avoid committing it.
  • Keep commands idempotent: Make repeated runs safe to avoid state issues.
  • Combine with cron/CI: Call ShellRun tasks from CI pipelines or cron jobs to centralize automation.

Handy shortcuts

  • Alias frequent tasks: Add shell aliases, e.g., alias sr=‘shellrun run’.
  • Tab completion: Enable shell completion if provided (e.g., source /etc/bash_completion.d/shellrun).
  • Parallel runs: Use shellrun run –parallel task1 task2 for independent tasks.
  • Logging: Redirect output to timestamped logs: shellrun run backup > logs/backup-$(date +%F-%T).log.

Troubleshooting

  • Permissions errors: Ensure scripts are executable: chmod +x scripts/*.sh.
  • Env differences: Use shellrun run -v to inspect the environment; match CI env to local if failures differ.
  • Dependency failures: Run dependent tasks individually to locate the failing step.

Example workflow

  1. shellrun init
  2. Define tasks in shellrun.yml (build → test → deploy)
  3. alias sr=‘shellrun run’
  4. Local: sr build → CI: sr deploy env=production

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *