✓
Passing This code compiles and runs correctly.
Code
// Test 655: Command declarations with subcommands
//
// command.declare should support nested subcommands so that complex CLI tools
// can be expressed declaratively. For example, `deps` has subcommands like `install`.
//
// ============================================================
// ASPIRATIONAL SYNTAX FOR command.declare
// ============================================================
//
// ~std.compiler:command.declare {
// "name": "deps",
// "description": "Manage system dependencies",
// "subcommands": [
// {
// "name": "install",
// "description": "Install missing dependencies",
// "flags": [
// { "name": "pm", "description": "Force package manager", "type": "string" }
// ]
// },
// {
// "name": "check",
// "description": "Check dependency status (default)"
// }
// ]
// }
//
// ============================================================
// WHAT deps.kz WOULD LOOK LIKE
// ============================================================
//
// Current deps.kz has:
//
// ~std.compiler:command.declare {
// "name": "deps",
// "description": "Check and install system dependencies..."
// }
//
// It would become:
//
// ~std.compiler:command.declare {
// "name": "deps",
// "description": "Manage system dependencies",
// "subcommands": [
// { "name": "install", "description": "Install missing dependencies" },
// { "name": "check", "description": "Check dependency status" }
// ]
// }
//
// ============================================================
// IMPLEMENTATION CHECKLIST
// ============================================================
//
// 1. Update CommandDeclaration struct in src/main.zig:
// const CommandDeclaration = struct {
// name: []const u8,
// description: []const u8,
// alias: ?[]const u8,
// subcommands: []SubcommandDeclaration, // <-- ADD THIS
// };
//
// const SubcommandDeclaration = struct {
// name: []const u8,
// description: []const u8,
// };
//
// 2. Update parseCommandDeclaration() to extract "subcommands" array
//
// 3. Update printDynamicHelp() to render subcommands, e.g.:
// deps [install|check] Manage system dependencies
// or:
// deps Manage system dependencies
// deps install Install missing dependencies
// deps check Check dependency status
//
// 4. Update koru_std/deps.kz to declare its subcommands
//
// ============================================================
// EXPECTED HELP OUTPUT
// ============================================================
//
// Commands:
// init Initialize a new Koru project
// zen Display the Zen of Koru
// deps [install|check] Manage system dependencies
//
// Run: koruc input.kz --help
// Expected: Help shows "deps" with indication of its subcommands
~import "$std/deps"
~event main {}
| done {}
~proc main {
return .{ .done = .{} };
}
~main()
| done |> _
Test Configuration
Post-validation Script:
#!/bin/bash
# Test that command.declare supports subcommands
#
# This test verifies that subcommands declared in command.declare
# appear in the help output. Currently FAILING until implemented.
set -e
echo "=== Testing: koruc input.kz --help should show subcommands ==="
# Capture help output
HELP_OUTPUT=$(koruc input.kz --help 2>&1)
echo "$HELP_OUTPUT"
echo ""
# First verify deps appears at all
if ! echo "$HELP_OUTPUT" | grep -q "deps"; then
echo "=== FAIL: 'deps' command not found (prerequisite) ==="
exit 1
fi
# The actual test: subcommands should be indicated
# Either "deps install" on its own line, or "deps [install|check]" compact form
if echo "$HELP_OUTPUT" | grep -qE "deps install|deps \[.*install"; then
echo "=== PASS: Subcommand 'install' indicated for deps ==="
else
echo "=== FAIL: Subcommand 'install' NOT shown for deps ==="
echo "Expected: Help should indicate that deps has subcommands"
echo "See input.kz for aspirational syntax"
exit 1
fi