Skip to content

CLI Arguments

Benjamin Kowarsch edited this page Jul 4, 2019 · 13 revisions

Command Format

m2pp information

or

m2pp sourcefile [options] [diagnostics]

Information Options

--help, -h
--version, -V
--license
--build-info

Help Option

The --help option prints usage information to the console.

Version Option

The --version option prints the executable's version to the console.

License Option

The --license option prints license information to the console.

Build-Info Option

The --build-info option prints the executable's build parameters to the console.

Processing Options

The following processing options are available.

--outfile
--dict
--tabwidth
--newline

Outfile Option

The --outfile option may be used to specify a custom target file name.

outfileOption :=
  '--outfile' filename
  ;

Dictionary Option

The --dict option may be used to pass key/value pairs to m2pp for placeholder expansion.

dictionaryOption :=
  '--dict' keyValuePair+
  ;

keyValuePair :=
  key '=' value
  ;

alias key, value = StdIdent;

StdIdent :=
  Letter ( Letter | Digit )*
  ;

Tabulator Option

The --tabwidth option may be used to set the tabulator width for ASCII TAB expansion. A value of 0 leaves TABs in the output. For values greater than 0 m2pp will replace TABs with spaces. The default value is 0.

tabWidthOption :=
  '--tabwidth' Digit
  ;

Newline Option

The --newline option may be used to set the newline mode. The default mode is LF.

newlineModeOption :=
  '--newline' ( 'cr' | 'lf' | 'crlf' )
  ;

Diagnostic Options

--verbose, -v
--show-settings

Examples

$ m2pp Stacks.gen.def --outfile IntStack.def --dict valueType=INTEGER maxDepth=100

Generates library interface IntStack.def from template Stacks.gen.def replacing each occurrence of placeholder valueType with INTEGER and any occurrence of placeholder maxDepth with 100.

$ m2pp Console.gen.mod --dict ver=iso

Generates ISO Modula-2 specific library module Console.iso.mod from template Console.gen.mod.

$ m2pp Jurassic.mod --tabwidth 4 --newline crlf

Reformats file Jurassic.mod by replacing each TAB with whitespace to match a tabulator width of four and replacing each end-of-line with CR LF.