Skip to content

Commit

Permalink
use console.log in favor of sys.puts
Browse files Browse the repository at this point in the history
  • Loading branch information
jfd committed Nov 2, 2011
1 parent c88ebe2 commit 718339f
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions examples/nodejs-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Import the optparse script
var optparse = require('../lib/optparse');

var sys= require('sys');

// Define some options
var SWITCHES = [
['-i', '--include-file FILE', "Includes a file"],
Expand Down Expand Up @@ -39,7 +37,7 @@ parser.on('include-file', function(value) {

// Handle the --print switch
parser.on('print', function(value) {
sys.puts('PRINT: ' + (value || 'No message entered'));
console.log('PRINT: ' + (value || 'No message entered'));
});

// Handle the --date switch
Expand All @@ -59,30 +57,30 @@ parser.on('debug', function() {

// Handle the --help switch
parser.on('help', function() {
sys.puts(parser.toString());
console.log(parser.toString());
print_summary = false;
});

// Set a default handler
parser.on('*', function(opt, value) {
sys.puts('wild handler for ' + opt + ', value=' + value);
console.log('wild handler for ' + opt + ', value=' + value);
});

// Parse command line arguments
parser.parse(process.ARGV);

if(print_summary) {
sys.puts("First non-switch argument is: " + first_arg);
console.log("First non-switch argument is: " + first_arg);

// Output all files that was included.
sys.puts("No of files to include: " + options.files.length);
console.log("No of files to include: " + options.files.length);
for(var i = 0; i < options.files.length; i++) {
sys.puts("File [" + (i + 1) + "]:" + options.files[i]);
console.log("File [" + (i + 1) + "]:" + options.files[i]);
}

// Is debug-mode enabled?
sys.puts("Debug mode is set to: " + options.debug);
console.log("Debug mode is set to: " + options.debug);

sys.puts("Number value is: " + options.number);
sys.puts("Date value is: " + options.date);
console.log("Number value is: " + options.number);
console.log("Date value is: " + options.date);
}

0 comments on commit 718339f

Please sign in to comment.