Command-line interface for the Lua 5.4 interpreter implemented in MoonBit.
moon buildmoon run cmd -- [OPTIONS] [SCRIPT] [ARGS...]Backend/I/O
- Preferred target is
js(seemoon.mod.json). - CLI file I/O uses synchronous Node bindings via
mizchi/js/node/fs(js.mbt), e.g.@fs.read_file_as_string(path). - Reference: https://github.com/mizchi/js.mbt
-v- Show version information-i- Enter interactive mode after executing script-E- Ignore environment variables-W- Turn warnings into errors
-e <code>- Execute a string of Lua code-l <library>- Load a library (can be specified multiple times)
SCRIPT- Lua script file to executeARGS...- Arguments passed to the script
moon run cmd -- -vOutput:
Lua 5.4.0 Copyright (C) 1994-2020 Lua.org, PUC-Rio
MoonBit port Copyright (C) 2025
moon run cmd -- -e "print('Hello, Lua!')"moon run cmd -- -l math -l stringmoon run cmd -- myscript.lua arg1 arg2 arg3moon run cmd -- -i -e "x = 10"moon run cmd -- -E -WThe CLI framework is complete and all command-line parsing works correctly. The following features are pending implementation:
- Actual Lua code execution (requires
lua/apiimplementation) - Interactive REPL (requires
lua/apiandlua/vmimplementation) - Library loading (requires
lua/stdlibimplementation) - Script file reading and execution
All command-line options are parsed and ready to be connected to the Lua interpreter once the core components are implemented.
The CLI uses the clap.mbt library for command-line argument parsing, which provides:
- Robust argument validation
- Automatic help generation
- Support for flags, named arguments, and positional arguments
- Error handling with descriptive messages
The implementation follows standard Lua command-line conventions and is compatible with Lua 5.4's CLI interface.