#! /usr/bin/env node
"use strict";

require('babel-polyfill');

function showHelpAndExit() {
    console.log("Usage: extract-messages [-m EXISTING] [-o OUTPUT] ...FILES/DIRECTORIES");
    console.log("Prints a JSON document with messages in FILES/DIRECTORIES mapped to themselves.");
    console.log("If -o is passed, writes to OUTPUT instead of stdout.");
    process.exit();
}

var argv = require('minimist')(process.argv.slice(2), {
    string: 'oh',
    alias: {o: 'output', h: 'help'}
});

if (argv._.length === 0 || argv.h) {
    showHelpAndExit();
}

var chalk = require('chalk');
var fs = require('fs');

var filesFromMixedPaths = require('./filesFromMixedPaths');
var extractFromPaths = require('../build/extract').default;

var output = extractFromPaths(argv._);
if (argv.o) {
    fs.writeFileSync(argv.o, output);
} else {
    console.log(output);
}

@@ -153,16 +153,37 @@
 OUTPUT%5D 
+%5B-f FORMAT (po%7Cjson)%5D
 ...FILES
@@ -228,13 +228,8 @@
 s a 
-JSON 
 docu
@@ -237,25 +237,75 @@
 ent 
-with messages in 
+(gettext PO format by default) with messages in%22)%0A    console.log(%22
 FILE
@@ -511,12 +511,15 @@
 ng: 
+%5B
 'oh
-'
+f'%5D
 ,%0A  
@@ -550,16 +550,29 @@
 : 'help'
+, f: 'format'
 %7D%0A%7D);%0A%0Ai
@@ -809,16 +809,16 @@
 fault;%0A%0A
-
 var outp
@@ -845,16 +845,50 @@
 s(argv._
+, %7B outputFormat: argv.f %7C%7C 'po' %7D
 );%0Aif (a

Add support for output format