aboutsummaryrefslogtreecommitdiffstats
path: root/bin/etatsbasen.js
diff options
context:
space:
mode:
Diffstat (limited to 'bin/etatsbasen.js')
-rwxr-xr-xbin/etatsbasen.js38
1 files changed, 30 insertions, 8 deletions
diff --git a/bin/etatsbasen.js b/bin/etatsbasen.js
index 9241e10..0960900 100755
--- a/bin/etatsbasen.js
+++ b/bin/etatsbasen.js
@@ -7,6 +7,8 @@ var pkg = require(path.join(__dirname, '..', 'package.json'));
var argv = require('minimist')(process.argv.slice(2));
var etatsbasen = require('etatsbasen');
+var defaultCategories = [12,14,17,18,27,33,38,66,68,76];
+
process.bin = process.title = 'etatsbasen';
if (argv.v) {
@@ -17,10 +19,28 @@ if (argv.v) {
var options = {};
options.filename = argv.f || 'etatsbasen.csv';
-if (argv.c && 'string' === typeof argv.c) {
- options.categories = argv.c.split(',');
-} else {
- options.categories = [];
+if (argv.c) {
+ if (Array.isArray(argv.c)) {
+ options.categories = argv.c;
+ } else if ('string' === typeof argv.c) {
+ if ('all' !== argv.c) {
+ options.categories = [argv.c];
+ }
+ } else {
+ options.categories = defaultCategories;
+ }
+}
+
+if (argv.o) {
+ if (Array.isArray(argv.o)) {
+ options.headers = argv.o;
+ } else if ('string' === typeof argv.o ||
+ 'number' === typeof argv.o) {
+ options.headers = [argv.o];
+ } else {
+ console.log('Unable to parse -o option(s)');
+ process.exit(1);
+ }
}
function fileNotFound() {
@@ -35,11 +55,13 @@ if (argv.h || fileNotFound()) {
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.'
+ ' -c [all|[c1,c2,..]] Categories to include (defaults: `' + defaultCategories.join(',') + '`)',
+ ' -f [file] File to read from (defaults: `etatsbasen.csv`)',
+ ' -o h1[,h2,h3] Include only these headers in output (id or name)',
+ ' -v Print version.',
+ ' -h Write this help.'
].join('\n'));
+
process.exit();
}