/hashfmt

format lines of text into textual hash format for json, python, or perl

Primary LanguageC++

Description:

This program formats lines of input, read from stdin,
into hash textual format for perl, json or python.

It supports options to insert line breaks and
to assign a name to the generated output hash.

usage: hashfmt [OPTIONS] LANGUAGE

OPTIONS:

  --help | -h : show this text

  --line-break N | -l N : print newline after every N elements

  --variable XX | -v XX : assign the resulting hash to a variable named XX

LANGUAGE is one of: json, perl, python

A simple tool, especially useful for code generation or testing.

Example:

    hashfmt -l 4 --variable months python <<EOS
    Jan 31
    Feb 28
    Mar 31
    Apr 30
    May 31
    Jun 30
    Jul 31
    Aug 31
    Sep 30
    Oct 31
    Nov 30
    Dec 31
    EOS

produces:

    months = {"Jan" : "31", "Feb" : "28", "Mar" : "31", "Apr" : "30", 
    "May" : "31", "Jun" : "30", "Jul" : "31", "Aug" : "31", 
    "Sep" : "30", "Oct" : "31", "Nov" : "30", "Dec" : "31"}

Author:

Gyepi Sam