cleanup structure
This commit is contained in:
70
run_examples.luash
Executable file
70
run_examples.luash
Executable file
@@ -0,0 +1,70 @@
|
||||
-- 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
|
||||
Reference in New Issue
Block a user