/xmfr

Primary LanguageJavaScriptMIT LicenseMIT

xmfr (Transformer)

This is a node-based CLI tool to transform structured data into a more human consumable format using templates.

Examples

Single JSON Object

$ cat single-item.json
{
   "animal": "Aardvark"
}
$ cat single-item.json | xmfr --print-context
{
   "record": { "animal": "Aardvark" },
   "records": [
      { "animal": "Aardvark" }
   ]
}

Array of JSON Objects

$ cat array-of-items.json
[
   { "animal": "Aardvark" },
   { "animal": "Beaver" },
   { "animal": "Capybara" }
]
$ cat array-of-items.json | xmfr --print-context
{
   "record": { "animal": "Aardvark" },
   "records": [
      { "animal": "Aardvark" },
      { "animal": "Beaver" },
      { "animal": "Capybara" }
   ]
}

Newline Delimited JSON Objects

$ cat newline-delimited-items.ndjson
{ "animal": "Aardvark" }
{ "animal": "Beaver" }
{ "animal": "Capybara" }
$ cat newline-delimited-items.ndjson | xmfr --print-context
{
   "record": { "animal": "Aardvark" },
   "records": [
      { "animal": "Aardvark" },
      { "animal": "Beaver" },
      { "animal": "Capybara" }
   ]
}

Markdown with Front Matter

$ cat document.md
---
title: Animals
---
Aardvark Beaver Capybara
$ cat newline-delimited-items.ndjson | xmfr --print-context
{
   "record": { "title": "Animals", "body", "Aardvark Beaver Capybara" },
   "records": [
      { "title": "Animals", "body", "Aardvark Beaver Capybara" }
   ]
}

Usage

Options

  • -t <path> / --template <path>
  • --print-context
  • --help

Install/Upgrade

npm i -g 'git@github.com:onebytegone/xmfr.git'

License

This software is released under the MIT license. See the license file for more details.