aboutsummaryrefslogtreecommitdiffstats
path: root/bin/etatsbasen.js
diff options
context:
space:
mode:
authorutvk <utvk@users.noreply.github.com>2014-05-08 23:49:12 +0200
committerutvk <utvk@users.noreply.github.com>2014-05-08 23:49:12 +0200
commitb6b812da1512678746dd0e2c797ae9563d650cbf (patch)
tree3db8f1214fa4689f673f5abfb2df097530043e9f /bin/etatsbasen.js
parentd45c808d56608f3ce37260914f52c75e50526764 (diff)
initial version
Diffstat (limited to 'bin/etatsbasen.js')
-rwxr-xr-xbin/etatsbasen.js53
1 files changed, 53 insertions, 0 deletions
diff --git a/bin/etatsbasen.js b/bin/etatsbasen.js
new file mode 100755
index 0000000..9699a93
--- /dev/null
+++ b/bin/etatsbasen.js
@@ -0,0 +1,53 @@
+#!/usr/bin/env node
+var path = require('path');
+var fs = require('fs');
+var pkg = require(path.join(__dirname, '..', 'package.json'));
+
+var argv = require('minimist')(process.argv.slice(2));
+var etatsbasen = require('etatsbasen');
+
+process.bin = process.title = 'etatsbasen';
+
+if (argv.v) {
+ console.log(pkg.version);
+ process.exit();
+}
+
+var options = {};
+options.filename = argv.f || 'etatsbasen.csv';
+
+if (argv.c && 'string' === typeof argv.c) {
+ options.categories = argv.c.split(',');
+} else {
+ options.categories = [];
+}
+
+function fileNotFound() {
+ return ! fs.existsSync(options.filename);
+}
+
+if (argv.h || fileNotFound()) {
+ if (fileNotFound()) {
+ console.log(process.title + ': ' + options.filename +
+ ': No such file or directory\n');
+ }
+ console.log([
+ 'usage: etatsbasen [options]',
+ '',
+ ' -c [c1,c2,..] Categories to include',
+ ' -f [file] File to read from (defaults: `etatsbasen.csv`)',
+ ' -v Print version.',
+ ' -h Write this help.'
+ ].join('\n'));
+ process.exit();
+}
+
+var ret = etatsbasen.printCSV(function(err) {
+ }, options);
+
+if (ret) {
+
+} else {
+ console.log('Unable to convert');
+ process.exit();
+}