-- Example Runner - Run all Luash examples in order -- Usage: ./luash run_examples.luash print("šŸš€ Luash Examples Runner") print("=" .. string.rep("=", 25)) -- Get list of examples examples = `ls examples/*.luash | sort` if examples == "" then print("āŒ No examples found in examples/ directory") os.exit(1) end local example_files = {} for file in examples:gmatch("[^\n]+") do table.insert(example_files, file) end print("\nFound " .. #example_files .. " examples:") for i, file in ipairs(example_files) do local name = file:match("examples/(.+)%.luash") print(string.format(" %d. %s", i, name)) end print("\n" .. string.rep("-", 50)) print("Choose an option:") print(" 1-" .. #example_files .. ": Run specific example") print(" a: Run all examples") print(" q: Quit") print(string.rep("-", 50)) io.write("Your choice: ") io.flush() choice = io.read() if choice == "q" then print("Goodbye!") os.exit(0) elseif choice == "a" then print("\nšŸŽ¬ Running all examples...\n") for i, file in ipairs(example_files) do local name = file:match("examples/(.+)%.luash") print(string.format("\n[%d/%d] Running %s", i, #example_files, name)) print(string.rep("=", 60)) local result = os.execute("./luash " .. file) if result ~= 0 then print("āŒ Example failed!") end if i < #example_files then print("\nPress Enter to continue...") io.read() end end print("\nāœ… All examples completed!") else local num = tonumber(choice) if num and num >= 1 and num <= #example_files then local file = example_files[num] local name = file:match("examples/(.+)%.luash") print("\nšŸŽ¬ Running " .. name .. "...") print(string.rep("=", 60)) os.execute("./luash " .. file) else print("āŒ Invalid choice: " .. choice) os.exit(1) end end