Skip to content

imgproxy/run.sh

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Caution

This is work in progress, use on your own risk.

run.sh

A Makefile replacement written in pure bash. No DSL, no runtime dependencies, no build step — just scripts.

Install

curl -fsSL https://raw.githubusercontent.com/imgproxy/run.sh/refs/heads/main/install.sh | bash -s -- -e

This sets up, in the current project:

  • run — the task dispatcher (regenerated by the installer; do not hand-edit)
  • .runrc — shared helpers and terminal color helpers, sourced once before any task runs (yours to edit)
  • bin/*.sh — one file per task

If ./bin already exists and is not empty, the installer skips creating it and skips scaffolding example tasks, writing a warning instead.

Usage

./run              # list available tasks
./run <task> [args...]
./run help <task>  # show a task's help text (when the help example task is installed)

Optional: global command

curl -fsSL https://raw.githubusercontent.com/imgproxy/run.sh/refs/heads/main/install.sh | bash -s -- -e -g

Installs run to ~/.local/bin, which walks up from your current directory to find the nearest run.sh project (like git finds .git), so you can run run <task> from any subdirectory instead of ../../run <task>.

Writing tasks

A task is a file at bin/<name>.sh defining three functions:

#!/usr/bin/env bash
# Sourced by ./run — do not execute directly.

description() { echo "One-line summary shown in ./run's task list"; }

help() {
  cat <<'EOF'
Usage: ./run <name> [args...]
EOF
}

main() {
  echo "task logic goes here, receives \"\$@\""
}

See examples/ for zero-arg, positional-arg, flag-parsing, and task-composition patterns.

Variables and helpers

./run sets a few variables and helpers before it calls your task's main():

  • PROJECT_ROOT — absolute path to the project root (the directory containing ./run).
  • TASK_DIR — absolute path to the task directory (e.g. bin).
  • require_tool <cmd> <message> — exit with a friendly error if <cmd> is not on PATH.
  • depends_on <task>... — run the named tasks in order and stop at the first failure.

.runrc is sourced once before any task runs, so helpers defined there are also available to tasks:

  • require_arg <flag-name> "$value" — fail if a required flag value is missing.
  • run_color_echo <color> <text> — print colored text when the terminal supports it.
  • NO_COLOR — set this environment variable to disable color output.

Dependencies

Compose tasks with depends_on inside a task's main():

main() {
  depends_on build test
  echo "deploying..."
}

depends_on runs each named task in order and stops at the first failure.

External libraries

run.sh itself has no runtime dependencies, but your tasks can use any tool you already have installed. Install libraries the same way you normally would (Homebrew, apt, npm, pip, etc.) and call them from your task files.

For reusable helpers, source them from .runrc:

# .runrc
. "$PROJECT_ROOT/vendor/some-lib.sh"

Use the built-in require_tool helper to fail early with a friendly message when a required command is missing:

main() {
  require_tool jq "jq is required (https://jqlang.github.io/jq/)"
  jq '.version' package.json
}

Philosophy

  • No DSL to learn — it's bash, all the way down.
  • No runtime dependency, no build step, no framework.
  • run is generated and regenerable; your logic lives in bin/ and .runrc, which re-installing never touches.
  • Compose tasks with depends_on task1 task2 in a task's main().

License

MIT

About

A Makefile replacement written in pure bash

Resources

License

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors