#!/usr/bin/env sh # okf — the okf CLI, backed by its Docker image (no Ruby on the host). # # Installed on your PATH by https://docker.okfgem.com/install.sh, this makes # `okf validate .`, `okf lint .`, and `okf server .` run the image with your # current directory mounted at /data. For `server` the port is published and the # bind address is opened for you. It is the same interface as the native CLI, so # the agent skill, the docs, and your muscle memory all work unchanged. # # install: curl -fsSL https://docker.okfgem.com/install.sh | sh # docs: https://docker.okfgem.com · https://okfgem.com/docs/docker/ # # Env: # OKF_IMAGE image to run (default: ghcr.io/serradura/okf:latest) # OKF_DOCKER docker command to use (default: docker) set -eu IMAGE="${OKF_IMAGE:-ghcr.io/serradura/okf:latest}" DOCKER="${OKF_DOCKER:-docker}" command -v "$DOCKER" >/dev/null 2>&1 || { echo "okf: '$DOCKER' not found — install Docker from https://docs.docker.com/get-docker/" >&2 exit 127 } # Allocate a TTY only when we actually have one, so pipes and CI still work. TTY="" [ -t 0 ] && [ -t 1 ] && TTY="-it" # `server` needs the port published and the bind opened; do both for the user # (the image's default 127.0.0.1 bind is unreachable from outside the container). EXTRA="" if [ "${1:-}" = "server" ]; then port=8808 # Honor an explicit -p/--port so the published port matches okf's. prev="" for arg in "$@"; do case "$prev" in -p|--port) port="$arg" ;; esac prev="$arg" done EXTRA="-p ${port}:${port}" # Bind to 0.0.0.0 unless the user already chose a bind address. case " $* " in *" --bind "*) : ;; *) set -- "$@" --bind 0.0.0.0 ;; esac fi # EXTRA and TTY are intentionally unquoted: each expands to zero or more words. exec "$DOCKER" run --rm $TTY $EXTRA -v "$PWD:/data" "$IMAGE" "$@"