cli-table-2-json

Convert command line table output into json object

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
cli-table-2-json
241.0.135 years ago8 years agoMinified + gzip package size for cli-table-2-json in KB

Readme

cli-table-2-json
Convert command line table output into json object
NPM NPM

Installation


npm install cli-table-2-json
Then:
var cliTable2Json = require('cli-table-2-json');

Usage:
var lines = ['NAME      ACTIVE   DRIVER      STATE     URL                         SWARM',
              'consul1   -        amazonec2   Running   tcp://54.175.200.212:2376   ',
              'consul2   -        amazonec2   Running   tcp://52.23.236.38:2376     ',
              'consul3   -        amazonec2   Running   tcp://54.85.111.241:2376    ',
              ''];

var result = cliTable2Json.cliTable2Json(lines);
console.log(result);

//[{
//  name: 'consul1',
//  active: '-',
//  driver: 'amazonec2',
//  state: 'Running',
//  url: 'tcp://54.175.200.212:2376',
//  swarm: ''
//},
//  {
//    name: 'consul2',
//    active: '-',
//    driver: 'amazonec2',
//    state: 'Running',
//    url: 'tcp://52.23.236.38:2376',
//    swarm: ''
//  },
//  {
//    name: 'consul3',
//    active: '-',
//    driver: 'amazonec2',
//    state: 'Running',
//    url: 'tcp://54.85.111.241:2376',
//    swarm: ''
//  }]

Typescript

import { cliTable2Json } from 'cli-table-2-json';

var lines = ['NAME      ACTIVE   DRIVER      STATE     URL                         SWARM',
  'consul1   -        amazonec2   Running   tcp://54.175.200.212:2376   ',
  'consul2   -        amazonec2   Running   tcp://52.23.236.38:2376     ',
  'consul3   -        amazonec2   Running   tcp://54.85.111.241:2376    ',
  ''];

var result = cliTable2Json(lines);
console.log(result);