Skip to content

Commit

Permalink
Add --header cli option to toggle hasCSVColumnTitle
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Radchenko committed Jun 4, 2015
1 parent d28ab40 commit 2965d3d
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions bin/json2csv.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
#!/usr/bin/env node

var program = require('commander'),
fs = require('fs'),
os = require('os'),
json2csv = require('../lib/json2csv'),
path = require('path'),
Table = require('cli-table');
var fs = require('fs');
var os = require('os');
var path = require('path');
var program = require('commander');
var Table = require('cli-table');
var json2csv = require('../lib/json2csv');
var pkg = require('../package');

program
.version('1.0.1')
.version(pkg.version)
.option('-i, --input <input>', 'Path and name of the incoming json file.')
.option('-o, --output [output]', 'Path and name of the resulting csv file. Defaults to console.')
.option('-f, --fields <fields>', 'Specify the fields to convert.')
.option('-l, --fieldList [list]', 'Specify a file with a list of fields to include. One field per line.')
.option('-d, --delimiter [delimiter]', 'Specify a delimiter other than the default comma to use.')
.option('-e, --eol [value]', 'Specify an EOL value after each row.')
.option('-h, --header', 'Disable the column name header')
.option('-p, --pretty', 'Use only when printing to console. Logs output in pretty tables.')
.parse(process.argv);

Expand Down Expand Up @@ -80,6 +82,7 @@ getFields(function(err, fields) {
getInput(function(err, input) {
var opts = {data: input, fields: fields};

if (program.header) opts.hasCSVColumnTitle = program.header;
if (program.delimiter) opts.del = program.delimiter;
if (program.eol) opts.eol = program.eol;

Expand Down

0 comments on commit 2965d3d

Please sign in to comment.