The mech
command-line tool provides various functionalities for working with Mech programs, including executing scripts, debugging, formatting code, and serving applications over HTTP. Below are the available options and subcommands.
mech [OPTIONS] [mech_paths]... [COMMAND]
Command | Description |
---|---|
| Format Mech source code into standard format. |
| Serve Mech program over an HTTP server. |
| Print help message. |
Source .mec files and directories. You can specify one or more .mec
files or directories containing Mech scripts. The command will execute the specified files in the order they are provided, and alpha-numeric sorting is applied to the files.
[mech_paths]...
Option | Description |
---|---|
| Prints debug information. |
| Prints the parse tree of the Mech program. |
| Measures execution time of the program. |
| Starts the Mech Read-Eval-Print Loop (REPL). |
To execute a Mech script, provide the path to one or more .mec
files or directories containing Mech scripts. The command will execute the specified files in the order they are provided:
mech program.mec mech script1.mec script2.mec dir1
Formats Mech source code into a standard format.
mech format [OPTIONS] [FILES]
Options:
Option | Value | Description |
---|---|---|
| | Specifies the output directory. |
| | Sets the stylesheet for HTML output. |
|
| Outputs formatted code as HTML. |
Example:
mech format -o formatted/ my_script.mec
Serves a Mech program over an HTTP server.
mech serve [OPTIONS] [FILES]
Options:
Option | Value | Description |
---|---|---|
| | Sets the port for the server (default: 8081). |
| | Sets the server address (default: 127.0.0.1). |
Example:
mech serve -p 3000 -a 0.0.0.0 my_script.mec
For more information on a specific command, you can use the --help
option with that command. For example:
mech --help mech serve --help