#!/usr/bin/env bash # SPDX-License-Identifier: MIT # Copyright 2026 Tristan Ancelet # # Runs flag_matrix.cr across every value source (default / env / CLI) for both # a global flag and a command argument, and checks each result. # # Each case needs its own process because env vars must be set before startup, # which is why this lives here rather than in spec/. # # ./utils/flag_matrix.sh (runnable from anywhere) # # Exits non-zero if any case does not match. set -u # Build from the PROJECT ROOT, not utils/. Two things depend on the CWD: # - `require "cligen"` resolves via ./lib/cligen (the self-symlink) # - command_node.cr renders ECR from the hardcoded relative path # "lib/cligen/src/cligen/template/cmd_help.ecr" # Building inside utils/ breaks both. cd "$(dirname "$0")/.." SRC=utils/flag_matrix.cr BIN=utils/flag_matrix pass=0 fail=0 echo "building..." if ! crystal build "$SRC" -o "$BIN" 2>&1 | grep -v sframe; then :; fi [ -x "$BIN" ] || { echo "build failed"; exit 1; } echo # check