Skip to main content

Function: mergeDocument()

mergeDocument(base, overrides): OpenCliDocument

Return a new document with overrides deep-merged onto base. Plain objects merge recursively (so info.license, global, and individual commands can be extended without repeating the rest). Arrays in overrides replace the base array, except examples and exitCodes, which append, and flags/args, which are merged item-by-item matched by name (so an author can add e.g. alternativeSources to one generated flag without repeating the whole flag list). Commands not present in base are added as-is.

Throws if the merged result fails OpenCLI schema validation, listing every problem found.

Parameters

base

OpenCliDocument

overrides

DocumentOverrides

Returns

OpenCliDocument