Skip to content

Commit

Permalink
Log the command if -l is given as a flag.
Browse files Browse the repository at this point in the history
  • Loading branch information
Max Murphy-Skvorzov committed Dec 6, 2014
1 parent 5c8e0ff commit f81e2ae
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bin/antijoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

var by = args['<join_key>']
Expand Down
6 changes: 5 additions & 1 deletion bin/clean.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ function parseJlineStream(stream, options) {
module.exports = parseJlineStream;

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

var exit = 0;
parseJlineStream(process.stdin)
.on('jline', function(record, lineNumber, line, recordNumber){console.log(line);})
Expand Down
2 changes: 1 addition & 1 deletion bin/foreach.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

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

var eventHandlers = [];
Expand Down
2 changes: 1 addition & 1 deletion bin/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Apply a function to each record.
var args = require('../lib/opt').fancy({filename:__filename, usage:
[ 'Usage: jline-foreach [--help|--version]'
, ' jline-foreach <cmd>...'
, ' jline-foreach [-l] <cmd>...'
].join("\n")});

var codes = args['<cmd>'].map(function(arg){
Expand Down
2 changes: 1 addition & 1 deletion bin/sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

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

var split = require('split')
Expand Down
2 changes: 1 addition & 1 deletion lib/opt.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ function handle(opts, vars, handlers){
function fancy(vars){
var ans = parse(vars);
process.stdout.on('error',process.exit);
console.log.apply(null,['#'].concat(process.argv.map(JSON.stringify)));
if(ans['-l'])console.log.apply(null,['#'].concat(process.argv.map(JSON.stringify)));
return ans;
}

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.35",
"version": "0.0.36",
"description": "Sort, grep and join files where every line is JSON.",
"main": "index.js",
"bin": {
Expand Down
2 changes: 2 additions & 0 deletions util/numper.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
# Usage:
# cat your.jlines | jline-numper

set -x

path="$(jline-parsePath "$1" | jline-foreach 'console.log(record.map(function(a){return JSON.stringify([a]);}).join(""))')"
echo "Collecting $path" >&2

Expand Down

0 comments on commit f81e2ae

Please sign in to comment.