056 user defined flags

✓ Passing This code compiles and runs correctly.

Code

// Test 656: User-defined flags appear in help
//
// Any library (not just stdlib) should be able to declare flags via
// ~std.compiler:flag.declare and have them show up in --help.
//
// This enables third-party libraries and user code to extend the CLI.
//
// Run: koruc input.kz --help
// Expected: Help shows --my-custom-flag in Backend Compiler Flags

~import "$std/compiler"

// User-defined flag
~std.compiler:flag.declare {
    "name": "my-custom-flag",
    "description": "A custom flag defined in user code",
    "type": "boolean"
}

// Another user flag with a value
~std.compiler:flag.declare {
    "name": "optimization-level",
    "description": "Set optimization level (0-3)",
    "type": "string"
}

~event main {}
| done {}

~proc main {
    return .{ .done = .{} };
}

~main()
| done |> _
input.kz

Test Configuration

Post-validation Script:

#!/bin/bash
# Test that user-defined flags appear in help
#
# Currently FAILING - this test documents the expected behavior.
# Any code can declare flags and they should appear in --help.

set -e

echo "=== Testing: koruc input.kz --help should show user-defined flags ==="

# Capture help output
HELP_OUTPUT=$(koruc input.kz --help 2>&1)

echo "$HELP_OUTPUT"
echo ""

# Check that user-defined flag appears
if echo "$HELP_OUTPUT" | grep -q "my-custom-flag"; then
    echo "=== PASS: --my-custom-flag discovered ==="
else
    echo "=== FAIL: --my-custom-flag NOT found ==="
    echo "Expected: User-defined flags should appear in Backend Compiler Flags"
    exit 1
fi

# Check for second flag
if echo "$HELP_OUTPUT" | grep -q "optimization-level"; then
    echo "=== PASS: --optimization-level discovered ==="
else
    echo "=== FAIL: --optimization-level NOT found ==="
    exit 1
fi