Permalink
Browse files

Merge pull request #8 from nschmoller/master

Replaced the sys module, to be compatible with node 0.7.x
  • Loading branch information...
zpoley committed Feb 29, 2012
2 parents e0a4bcd + de7d717 commit 5a1699e0c9b2cea1edc9bd72aa37c6147fc29aa4
Showing with 38 additions and 39 deletions.
  1. +1 −2 bin/json.js
  2. +37 −37 lib/jsonCommand.js
View
@@ -1,7 +1,6 @@
#!/usr/bin/env node
-var sys = require("sys"),
- jsonCommand = require("../lib/jsonCommand");
+var jsonCommand = require("../lib/jsonCommand");
var args = process.argv.slice(0);
// shift off node and script name
View
@@ -1,4 +1,4 @@
-var sys = require("sys"),
+var util = require("util"),
vm = require("vm");
/*
@@ -30,45 +30,45 @@ JSON.Command = function(args) {
};
JSON.Command.prototype.printhelp = function() {
- sys.puts("usage: stdout_generator | json [options] [fields]");
- sys.puts("");
- sys.puts("json processes standard input and parses json objects. json currently handles a");
- sys.puts("few different standard input formats and provides a number of options tailored");
- sys.puts("toward inspecting and transforming the parsed json objects.");
- sys.puts("");
- sys.puts("options:\n");
- sys.puts(" -h print this help info and exit\n");
- sys.puts(" -v (-V | --version) print version number and exit\n");
- sys.puts(" -u print ugly json output, each object on a single line\n");
- sys.puts(" -d print debugging output including exception messages\n");
- sys.puts(" -o object.path specify the path to an array to be iterated on\n");
- sys.puts(" new.key=old_key move old_key to new.key in output object\n");
- sys.puts(" -a input object is an array, process each element separately\n");
- sys.puts(" -c \"js conditional\" js conditional to be run in the context of each object");
- sys.puts(" that determines whether an object is printed\n");
- sys.puts(" -C print the output fields as tab delimited columns in");
- sys.puts(" the order specified by fields\n");
- sys.puts(" -e \"js expression\" execute arbitrary js in the context of each object.\n");
- sys.puts(" -i use node's sys.inspect instead of JSON.stringify\n");
- sys.puts(" -H print headers, if they are supplied.");
- sys.puts(" Useful for output from curl -i.\n");
-
- sys.puts("examples:\n");
- sys.puts(" curl http://search.twitter.com/search.json?q=node.js 2> /dev/null |");
- sys.puts(" json -o results\n");
- sys.puts(" curl http://search.twitter.com/search.json?q=node.js 2> /dev/null |");
- sys.puts(" json -o results new_id=id\n");
- sys.puts(" curl http://search.twitter.com/search.json?q=node.js 2> /dev/null |");
- sys.puts(" json -o results -C from_user from_user_id text\n");
- sys.puts("more help:\n");
- sys.puts(" use \"man json\" or visit http://github.com/zpoley/json-command\n");
+ console.log("usage: stdout_generator | json [options] [fields]");
+ console.log("");
+ console.log("json processes standard input and parses json objects. json currently handles a");
+ console.log("few different standard input formats and provides a number of options tailored");
+ console.log("toward inspecting and transforming the parsed json objects.");
+ console.log("");
+ console.log("options:\n");
+ console.log(" -h print this help info and exit\n");
+ console.log(" -v (-V | --version) print version number and exit\n");
+ console.log(" -u print ugly json output, each object on a single line\n");
+ console.log(" -d print debugging output including exception messages\n");
+ console.log(" -o object.path specify the path to an array to be iterated on\n");
+ console.log(" new.key=old_key move old_key to new.key in output object\n");
+ console.log(" -a input object is an array, process each element separately\n");
+ console.log(" -c \"js conditional\" js conditional to be run in the context of each object");
+ console.log(" that determines whether an object is printed\n");
+ console.log(" -C print the output fields as tab delimited columns in");
+ console.log(" the order specified by fields\n");
+ console.log(" -e \"js expression\" execute arbitrary js in the context of each object.\n");
+ console.log(" -i use node's util.inspect instead of JSON.stringify\n");
+ console.log(" -H print headers, if they are supplied.");
+ console.log(" Useful for output from curl -i.\n");
+
+ console.log("examples:\n");
+ console.log(" curl http://search.twitter.com/search.json?q=node.js 2> /dev/null |");
+ console.log(" json -o results\n");
+ console.log(" curl http://search.twitter.com/search.json?q=node.js 2> /dev/null |");
+ console.log(" json -o results new_id=id\n");
+ console.log(" curl http://search.twitter.com/search.json?q=node.js 2> /dev/null |");
+ console.log(" json -o results -C from_user from_user_id text\n");
+ console.log("more help:\n");
+ console.log(" use \"man json\" or visit http://github.com/zpoley/json-command\n");
process.exit();
};
JSON.Command.prototype.printversion = function() {
var npm = require("npm");
npm.load([], function(er) {
- sys.print("json command line toolkit\n version: ");
+ console.log("json command line toolkit\n version: ");
npm.commands.view([ "json", "version" ], function(er, data) {
process.exit();
});
@@ -77,13 +77,13 @@ JSON.Command.prototype.printversion = function() {
JSON.Command.prototype.stringify = function(obj) {
- return( this.inspectOutput ? sys.inspect(obj, false, Infinity, true)
+ return( this.inspectOutput ? util.inspect(obj, false, Infinity, true)
: this.uglyOutput ? JSON.stringify(obj)
: JSON.stringify(obj, null, 2) );
};
JSON.Command.prototype.debug = function(msg) {
- if (this.debugOn) { sys.puts(msg); }
+ if (this.debugOn) { console.log(msg); }
};
JSON.Command.prototype.printex = function(ex) {
@@ -144,7 +144,7 @@ JSON.Command.prototype.processArgs = function processArgs(args) {
case "-a": // array
this.inputIsArray = true;
break;
- case "-i": // use sys.inspect
+ case "-i": // use util.inspect
this.inspectOutput = true;
break;
case "-H": // header passthrough

0 comments on commit 5a1699e

Please sign in to comment.