Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update cli handling to use latest bagofholding, first go at updating …
…tests to use busterjs.
- Loading branch information
Showing
8 changed files
with
208 additions
and
256 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -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'" } | |||
] | |||
} | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,40 +1,27 @@ | |||
var _ = require('underscore'), | var bag = require('bagofholding'), | ||
bag = require('bagofholding'), | DataGen = require('./datagen'); | ||
fs = require('fs'), |
|
||
p = require('path'), | function _init() { | ||
datagen = require('./datagen'); | 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 exec() { | ||
|
|
||
function _init() { | var actions = { | ||
new datagen().init(bag.cli.exit); | commands: { | ||
} | init: { action: _init }, | ||
|
gen: { action: _generate } | ||
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 | |||
} | } | ||
}; | }; | ||
|
|
||
bag.cli.parse(commands, __dirname); | bag.cli.command(__dirname, actions); | ||
} | } | ||
|
|
||
exports.exec = exec; | exports.exec = exec; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.