nmm init
Generate a valid module.json manifest.
📝Syntax
module_json_path = nmm('init', destination_dir, field1, value1, ...)
data = nmm('init', destination_dir, ..., 'DryRun', true)
module_json_path = nmm('init', destination_dir, ..., 'Force', true)
module_json_path = nmm('init', destination_dir, ..., 'Skeleton', true)
module_json_path = nmm('init', destination_dir, 'Interactive', true)
📥Input Arguments
Parameter Description
destination_dir a string: directory where module.json is written (created if it does not exist).
field1, value1, ... name/value pairs describing the manifest and the command options (see the description).
📤Output Arguments
Parameter Description
module_json_path a string: full path of the written module.json file.
data a struct: the assembled manifest, returned when 'DryRun' is true (nothing is written).
📄Description

nmm('init', destination_dir, ...) assembles a module.json manifest from the supplied fields and sensible defaults, validates it with the same schema validator used by nmm('validate'), and writes a pretty-printed module.json in destination_dir. Because it reuses nmm's own validator, a generated manifest is always nmm-valid.

Manifest fields accepted as name/value pairs:

module a string module name matching ^[A-Za-z][A-Za-z0-9_]*$; defaults to the destination folder name (or the title) when omitted.

title, summary non-empty strings; title defaults to the module name and summary defaults to the title.

version a semantic version; defaults to 1.0.0.

license a SPDX license expression (for example MIT or LGPL-3.0-or-later); required.

platforms a string or cell of strings; defaults to {'all'}.

nelson a Nelson version range; defaults to >=2.0.0.

builtin a logical; defaults to false.

dependencies a struct mapping module names to version constraints; defaults to an empty struct.

keywords, authors, description, repository, homepage, issues, documentation optional metadata.

Command options:

'Force', true overwrites an existing module.json (otherwise the command errors).

'DryRun', true returns the assembled manifest struct without writing any file.

'Skeleton', true also drops a minimal loadable, package-ready source tree next to the manifest (loader.m, builder.m, etc/startup.m, etc/finish.m, help and tests). It is intentionally minimal; use a dedicated scaffolder for a richer module.

'Interactive', true prompts with input() for any required field that was not supplied, showing the default in brackets and validating each answer. It is disabled by default so that scripts run through --file never block on standard input.

After writing (or computing, on DryRun) the manifest, init runs nmm's own best-practice warnings linter (the same one as nmm('validate', ..., '-warnings')) and echoes non-fatal suggestions for recommended metadata that is missing, such as repository, authors, keywords or description. Warnings never stop the manifest from being written. On DryRun the returned struct also carries a warnings field.

The generated manifest is directly usable by nmm('validate') and, for a source module, by nmm('pack').

💡Examples
Generate a manifest and validate it
module_dir = [tempdir(), 'my_module/'];
mkdir(module_dir);
nmm('init', module_dir, 'module', 'my_module', 'title', 'My Module', ...
    'summary', 'a demo module', 'license', 'MIT', 'Skeleton', true);
nmm('validate', module_dir)
🔗See Also
nmmmodule.json
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub