Skip to content

feat: add derive command - #7

Merged
jackchuka merged 1 commit into
mainfrom
feat/2025-09-18-derive
Sep 18, 2025
Merged

feat: add derive command#7
jackchuka merged 1 commit into
mainfrom
feat/2025-09-18-derive

Conversation

@jackchuka

Copy link
Copy Markdown
Owner

This pull request introduces a new "derive" command to the CLI, allowing users to infer a schema from an existing Markdown document. The schema inference logic is implemented in a new package, and comprehensive tests are included to ensure correct behavior, including handling of front matter and heading hierarchies.

New CLI command:

  • Added a derive subcommand (NewDeriveCmd) to the CLI, which analyzes a Markdown file and generates a schema reflecting its heading hierarchy. The command supports outputting the schema to a file or stdout. [1] [2]

Schema inference logic:

  • Implemented the infer package with a FromDocument function that builds a schema from a parsed Markdown document, correctly handling heading levels and skipping front matter.

Testing:

  • Added tests for the inference logic, covering correct schema construction, error handling for documents without headings, and proper skipping of front matter.

@jackchuka
jackchuka merged commit c94d4f2 into main Sep 18, 2025
1 check passed
@jackchuka
jackchuka deleted the feat/2025-09-18-derive branch September 18, 2025 08:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant