v0.1.0 is out

Scripts that run everywhere.

ok is a scripting language and task runner in one static binary. It replaces hard-to-read bash, Python or JS scripts that need a runtime, and Makefiles. The same script runs on Linux, macOS and Windows.

curl -fsSL https://okrun.dev/install.sh | sh
irm https://okrun.dev/install.ps1 | iex

Downloads the binary for your machine from the latest release and checks its SHA-256. Read the install.sh / install.ps1 source first, or download the binary yourself.

Readable scripts, with data built in

JSON, CSV, YAML and TOML are values, not text to parse. Pipelines read like the task they do, and a script's main signature is its command line, --help included.

active-users.ok
# Convert a CSV export to JSON, keeping only active users
fn main(input: path, --out: path = "active.json") {
  read(input)
    | where .active == "true"
    | sort .name
    | write(out)
  let n = read(out) | count
  print("wrote {n} users to {out}")
}
terminal
$ ok active-users.ok users.csv
wrote 2 users to active.json

$ ok active-users.ok --help
Convert a CSV export to JSON, keeping only active users

Usage: ok active-users.ok <input> [--out <path>]

Arguments:
  <input>

Options:
  --out <path>  [default: active.json]
  -h, --help    print this help

A task runner that needs nothing installed

Tasks live in ok.ok. ok self init adds small ./ok and ok.cmd wrappers that fetch the pinned, checksum-verified ok on first use, so contributors and CI just run ./ok build.

ok.ok
let image = "ghcr.io/example/api"

# Build the container image
task image {
  let sha = (run git rev-parse --short HEAD).out
  run docker build -t {image}:{sha} .
}

# Run the image locally
task serve(--port: int = 8080) needs [image] {
  let sha = (run git rev-parse --short HEAD).out
  run docker run --rm -p {port}:8080 {image}:{sha}
}
terminal
$ ok
api (~/code/api)

  image        Build the container image
  serve        Run the image locally

$ ok serve --port 3000
# runs image first, then serve

$ ok --dry-run serve
# prints the docker commands without running them

Why ok

Everything a script needs is in one file you can drop on any machine.

No shell, no quoting bugs

run starts programs directly. Each {value} is exactly one argument, whatever it contains.

Portable standard library

Files, globs, paths, regex, time, hashing, HTTPS fetch and zip/tar, the same on every OS. No coreutils needed.

One static binary

About 6 MB, no runtime, no dependencies. Linux, macOS and Windows on x86-64 and arm64.

Errors that help

Every error points at the line, underlines the problem and, where it can, says how to fix it.

Safe by default

A cloned project's tasks ask before they run, and ask again when the files change.

Free and open

MIT or Apache-2.0. Read the spec, try the examples, each next to the script it replaces.