Skip to content

Commit

Permalink
+= flag to silence comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Murphy-Skvorzov committed Oct 1, 2015
1 parent f4826fb commit 289fc4b
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
6 changes: 3 additions & 3 deletions bin/foreach.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

// Execute some code for each record.

require('../lib/opt').fancy({filename:__filename, usage:
var opt = require('../lib/opt').fancy({filename:__filename, usage:
[ 'Usage: jline-foreach [--help|--version]'
, ' jline-foreach [-l] <cmd>...'
, ' jline-foreach [-l] [-q] <cmd>...'
].join("\n")});

var eventHandlers = [];
Expand Down Expand Up @@ -67,7 +67,7 @@ function flatten(data, callback, prefix, maxdepth) {


var source = require('./clean')(process.stdin);
source.on('comment', function(c){console.log(c);});
if (!opt["-q"])source.on('comment', function(c){console.log(c);});
eventHandlers.forEach(function(tuple){
var event = tuple[0].toLowerCase();
var code = Function('require','emit','keyvals','setpath','getpath','tm','find','flatten', 'record', 'lineNumber', 'line', 'recordNumber', tuple[1])
Expand Down
6 changes: 6 additions & 0 deletions bin/foreach.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ Execute a function for each JSON line. This is roughly equivalent to gawk for J

### Code

The flags are:

* `-q` - quiet - don't pass comments through.

* `-l` - log - start the output with a comment giving this command

Each argument is of the form: "event::code". If the event is omitted it is assumed to be `jline`. Others are:

* `beginning`/`beg`/`begin`
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jline",
"version": "0.0.40",
"version": "0.0.41",
"description": "Sort, grep and join files where every line is JSON.",
"main": "index.js",
"bin": {
Expand Down

0 comments on commit 289fc4b

Please sign in to comment.