Command Line Interface
Stable
CLI options are stable in Levython 1.0.
The levython command is the main entry point for running Levython programs and accessing
tools.
Table of Contents
Synopsis#
levython [options] [file] [arguments]
Running Programs#
Run a Levython file:
terminal
# Run a .levy file
levython program.levy
# Run a .ly file (short extension)
levython program.ly
# Run from stdin
echo 'say("Hello!")' | levython -
# Run inline code
levython -e 'say("Hello!")'
Options#
| Option | Description |
|---|---|
--version, -v |
Print version information |
--help, -h |
Display help message |
-e <code> |
Execute code from command line |
- |
Read program from stdin |
--debug |
Enable debug output |
--ast |
Print parsed AST |
--time |
Show execution time |
terminal
# Version
$ levython --version
Levython 1.0.0 (x86-64 JIT)
# Help
$ levython --help
Usage: levython [options] [file] [args...]
Options:
--version, -v Print version
--help, -h Show this message
-e Execute inline code
--debug Debug mode
--ast Print AST
--time Show timing info
# Time execution
$ levython --time fibonacci.levy
Result: 9227465
Execution time: 45ms
Package Manager#
Access the package manager through the CLI:
terminal
# Install a package
levython lpm install math
# List installed packages
levython lpm list
# Remove a package
levython lpm remove math
# Or use the lpm command directly
lpm install math
See Package Manager (LPM) for complete documentation.
Examples#
Quick One-Liners
terminal
# Print something
levython -e 'say("Hello, World!")'
# Do math
levython -e 'say(str(2 + 2))'
# Process piped input
echo "42" | levython -e 'say("Number: " + input())'
Running Tutorial Examples
terminal
# Clone the repo
git clone https://github.com/levython/Levython.git
cd Levython
# Run examples
levython examples/01_hello_world.levy
levython examples/09_fibonacci.levy
Performance Benchmarking
terminal
# Time the fibonacci benchmark
$ levython --time examples/09_fibonacci.levy
fib(35) = 9227465
Execution time: 45ms
# Compare with Python
$ time python3 -c "
def fib(n):
return n if n <= 1 else fib(n-1) + fib(n-2)
print(fib(35))
"
# Output: ~2300ms