retter
> Allows you to extract values (to JSON) out of a file or stdin based on a mustach template definition.
Last updated 3 years ago by beevelop .
Apache-2.0 · Original npm · Tarball · package.json
$ cnpm install retter 
SYNC missed versions from official npm registry.

retter – REverse TemplaTing ExtractoR

Allows you to extract values (to JSON) out of a file or stdin based on a mustach template definition.

Quick start

  1. Install retter: npm i -g retter
  2. Define template (mustache Syntax)
  3. Get your content (save as file or prepare to pipe into retter)
  4. Run retter
  • Stdin: cat content.file | retter template.mustache
  • File: retter template.mustache content.txt

Use case

retter is supposed to save you some headache when parsing command line output or files. Using awk, sed, grep and all their other friends is suitable for nerve-racking hours of trial and error – if you want to get this stuff done fast use retter. Typical use case: Some awesome command line tool generates the very same (but different) output every time (like every freakin' CI automation does). Now you want to get the data / values extracted from the output for further processing / analysis / whatever.

Further processing

You can use jq, a lightweight and flexible command-line JSON processor, to process the results even further.

retter examples/template examples/content | jq '[.issues]'

Example (parsing a Sonarlint output)

Template

-------------  SonarLint Report  -------------

          {{issues}} issues ({{files}} files analyzed)

          {{blocker}} blocker
          {{critical}} critical
          {{major}} major
          {{minor}} minor
          {{info}} info

-------------------------------------------

Content

-------------  SonarLint Report  -------------

          11280 issues (3577 files analyzed)

          131 blocker
          1170 critical
          5984 major
          3951 minor
          44 info

-------------------------------------------

Command

$ retter examples/template examples/content
{ issues: '11280',
  files: '3577',
  blocker: '131',
  critical: '1170',
  major: '5984',
  minor: '3951',
  info: '44' }

Current Tags

  • 0.0.1                                ...           latest (3 years ago)

1 Versions

  • 0.0.1                                ...           3 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 1
Last Month 1
Dependencies (3)
Dev Dependencies (0)
None
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |