The Grain CLIEdit on GitHub
The Grain CLI is an all-in-one tool for compiling, running, documenting, and formatting all of your Grain programs.
The top level
grain command will compile and run a Grain program. This can be useful during development for quick iteration cycles. The flags available for this command are equivalent to the flags for
Compiles a Grain program to WebAssembly.
All of the supported flags can be found below:
||add additional dependency include directories|
||override the standard libary with your own|
||initial number of WebAssembly memory pages|
||maximum number of WebAssembly memory pages|
||compilation mode (advanced use only)|
|–elide-type-info||don’t include runtime type information used by toString/print|
|–release||compile using the release profile (production mode)|
|–experimental-wasm-tail-call||enables tail-call optimization|
|–debug||compile with debugging information|
|–wat||additionally produce a WebAssembly Text (.wat) file|
|–hide-locs||hide locations from intermediate trees. Only has an effect with
|–no-color||disable colored output|
|–no-gc||turn off reference counting garbage collection|
|–no-bulk-memory||polyfill WebAssembly bulk memory instructions|
||path to custom WASI implementation|
|–use-start-section||replaces the _start export with a start section during linking|
|–no-link||disable static linking|
|–no-pervasives||don’t automatically import the Grain Pervasives module|
||debugging level for parser output|
||set the base address for the Grain heap|
|–source-map||generate source maps|
|–strict-sequence||enable strict sequencing|
|–verbose||print critical information at various stages of compilation|
|-h, –help||display help for command|
Runs a WebAssembly file. The
grain run command can run Grain programs compiled with
--no-link, and can also run WebAssembly files produced by other compilers.
It should be noted that
grain run is used here on the WebAssembly file produced via
Produces documentation for a Grain program. See the full Graindoc page to learn more!
Generating docs for a single file on stdout:
Generating docs for a single file:
Generating docs for an entire project:
Formats Grain files. Running
grain format on a single file will write the formatted file on stdout, and the result can be written to a file via the
grain format can also be used on a directory to format all of the Grain files in a project.
Formatting a single file to stdout:
Formatting a single file in place:
Formatting a project in place:
Starts a Grain language server. Generally, this command is used by your code editor to display information about your programs as you write them, and you never need to worry about using this command manually. You can learn more about the Language Server Protocol here.