Permalink
Browse files

Update cli handling to use latest bagofholding, first go at updating …

…tests to use busterjs.
  • Loading branch information...
cliffano committed Mar 7, 2013
1 parent 9b82277 commit 6f82250c7bacbd2f36e69e258ea1de937893848d
Showing with 208 additions and 256 deletions.
  1. +16 −0 conf/commands.json
  2. +16 −29 lib/cli.js
  3. +2 −2 lib/functions.js
  4. +7 −9 package.json
  5. +2 −1 test/cli.js
  6. +2 −1 test/datagen.js
  7. +161 −213 test/functions.js
  8. +2 −1 test/worker.js
View
@@ -0,0 +1,16 @@
+{
+ "commands": {
+ "init": {
+ "desc": "Create sample template files\nUsage: datagen init"
+ },
+ "gen": {
+ "desc": "Generate data file\nUsage: datagen [-i/--gen-id <genId>] [-s/--num-segments <numSegments>] [-w/--num-workers <numWorkers>] [-o/--out-file <outFile>] gen",
+ "options": [
+ { "arg": "-i, --gen-id <genId>", "desc": "An ID unique to the current data generation, used by all worker processes | defaut: datagen process PID" },
+ { "arg": "-s, --num-segments <numSegments>", "desc": "How many segments in a data file | default: 1" },
+ { "arg": "-w, --num-workers <numWorkers>", "desc": "How many worker processes, each worker creates a data file | default: 1" },
+ { "arg": "-o, --out-file <outFile>", "desc": "Generated data file name, postfixed with worker ID | default: 'data'" }
+ ]
+ }
+ }
+}
View
@@ -1,40 +1,27 @@
-var _ = require('underscore'),
- bag = require('bagofholding'),
- fs = require('fs'),
- p = require('path'),
- datagen = require('./datagen');
+var bag = require('bagofholding'),
+ DataGen = require('./datagen');
+
+function _init() {
+ new DataGen().init(bag.cli.exit);
+}
+
+function _generate(args) {
+ new DataGen().generate(args.genId, parseInt(args.numSegments, 10), parseInt(args.numWorkers, 10), args.outFile, bag.cli.exit);
+}
/**
- * Execute datagen using header, segment, and footer files in the current directory.
+ * Execute DataGen CLI.
*/
function exec() {
- function _init() {
- new datagen().init(bag.cli.exit);
- }
-
- function _generate(args) {
- new datagen().generate(args.genId, args.numSegments, args.numWorkers, args.outFile, bag.cli.exit);
- }
-
- var commands = {
- init: {
- desc: 'Create example template files',
- action: _init
- },
- gen: {
- desc: 'Generate data file',
- options: [
- { arg: '-i, --gen-id <genId>', desc: 'An ID unique to the current data generation, used by all worker processes | defaut: datagen process PID' },
- { arg: '-s, --num-segments <numSegments>', desc: 'How many segments in a data file | default: 1', action: parseInt },
- { arg: '-w, --num-workers <numWorkers>', desc: 'How many worker processes, each worker creates a data file | default: 1', action: parseInt },
- { arg: '-o, --out-file <outFile>', desc: 'Generated data file name, postfixed with worker ID | default: \'data\'' }
- ],
- action: _generate
+ var actions = {
+ commands: {
+ init: { action: _init },
+ gen: { action: _generate }
}
};
- bag.cli.parse(commands, __dirname);
+ bag.cli.command(__dirname, actions);
}
exports.exec = exec;
View
@@ -1,7 +1,7 @@
var dateFormat = require('dateformat'),
faker = require('Faker'),
- nonsense = require('Nonsense'),
- ns = new nonsense();
+ Nonsense = require('Nonsense'),
+ ns = new Nonsense();
/**
* Template function to generate a random integer.
View
@@ -31,17 +31,15 @@
"test": "./test"
},
"dependencies": {
- "bagofholding": "0.0.12",
- "dateformat": "1.0.2-1.2.3",
- "Faker": "0.1.3",
- "ncp": "0.2.6",
+ "bagofholding": "0.1.2",
+ "dateformat": "1.0.4-1.2.3",
+ "Faker": "0.5.6",
+ "ncp": "0.4.0",
"Nonsense": "0.1.2",
- "underscore": "1.3.3"
+ "underscore": "1.4.4"
},
"devDependencies": {
- "mocha": "1.3.2",
- "sandboxed-module": "0.1.3",
- "should": "1.1.0"
+ "buster": "0.6.12"
},
"scripts": {},
"engines": {
@@ -53,4 +51,4 @@
"url": "http://github.com/cliffano/datagen/raw/master/LICENSE"
}
]
-}
+}
View
@@ -1,3 +1,4 @@
+/*
var bag = require('bagofholding'),
sandbox = require('sandboxed-module'),
should = require('should'),
@@ -84,4 +85,4 @@ describe('cli', function () {
});
});
});
-
+*/
View
@@ -1,3 +1,4 @@
+/*
var bag = require('bagofholding'),
_jscov = require('../lib/datagen'),
sandbox = require('sandboxed-module'),
@@ -96,4 +97,4 @@ describe('datagen', function () {
});
});
});
-
+*/
Oops, something went wrong.

0 comments on commit 6f82250

Please sign in to comment.