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]
format - Format Mech source code into standard format.
serve - Serve Mech program over an HTTP server.
help - Print this message or the help of the given subcommand(s)
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]...
-d
, --debug
Prints debug information.
-e
, --tree
Prints the parse tree of the Mech program.
-t
, --time
Measures execution time of the program.
-r
, --repl
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:
-o
, --out
Specifies the output directory.
-s
, --stylesheet
Sets the stylesheet for HTML output.
-t
, --html
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:
-p
, --port [PORT]
Sets the port for the server (default: 8081).
-a
, --address [ADDRESS]
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