✓
Passing This code compiles and runs correctly.
Code
// Pins that `koruc <file> --flag <command>` refuses instead of silently
// building. Command detection takes the arg immediately after the input
// file; a flag in that slot used to strand the real command in the tail,
// where it was ignored and a normal build ran instead.
//
// koruc input.kz --build=dev ordercmd → refusal, exit 1
// koruc input.kz ordercmd --build=dev → command runs
~import std/compiler
~std/compiler:command.declare {
"name": "ordercmd",
"description": "Command used to pin command-position enforcement"
}
~[comptime|command]pub tor ordercmd {
program: *const Program,
allocator: __koru_std.mem.Allocator,
argv: []string,
}
const std = @import("std");
~proc ordercmd|zig {
std.debug.print("ordercmd ran\n", .{});
}
~tor main {}
~proc main|zig {
}
~main()
Flows
flow ~command.declare click a branch to expand · @labels scroll to their anchor
command.declare (source: "name": "ordercmd",
"description": "Command used to pin command-position enforcement")
flow ~main click a branch to expand · @labels scroll to their anchor
main
Test Configuration
Post-validation Script:
#!/bin/bash
# The failure this pins: a flag before the command used to fall through to a
# normal build, ignoring the command entirely. Correct behavior is a nonzero
# refusal naming the command, while command-first order still runs it.
set -e
if koruc "$KORU_INPUT" --build=dev ordercmd > /tmp/koru_134_out 2>&1; then
echo "FAIL: flag-first invocation did not refuse"
cat /tmp/koru_134_out
exit 1
fi
grep -q "'ordercmd' is a command" /tmp/koru_134_out || {
echo "FAIL: refusal did not name the command"
cat /tmp/koru_134_out
exit 1
}
koruc "$KORU_INPUT" ordercmd --build=dev > /tmp/koru_134_ok 2>&1
grep -q "ordercmd ran" /tmp/koru_134_ok || {
echo "FAIL: command-first invocation did not run the command"
cat /tmp/koru_134_ok
exit 1
}