// Push records from JSON to Data Service
var fs = require('fs');
var request = require('request');

var usage = function() {
  console.log("\nUsage: node push.js <input records> <destination URL>");
  console.log("Example: node push.js output.json \"http://data-service.geocens.ca/...\"");
  console.log("URL should point to record resource on Data Service.")
};

if (process.argv.length !== 4) {
  console.log("Error! not enough arguments");
  usage();
  process.exit(1);
};

var uploadEndpoint = process.argv[3];

var file = process.argv[2];
fs.readFile(file, 'utf8', function (err, data) {
  if (err) {
    console.log("Error: " + err);
    return;
  }

  uploadRecords(JSON.parse(data));
});

var uploadRecords = function (records) {
  records.forEach(function (record) {
    uploadRecord(record);
  });
};

var uploadRecord = function (record) {
  request.post({
    uri: uploadEndpoint,
    json: JSON.stringify(record)
  }, function (e, r, body) {
    console.log("Upload complete", r.statusCode);
  });
};

@@ -102,378 +102,108 @@
 var 
-usage = function() %7B%0A  console.log(%22%5CnUsage: node push.js %3Cinput records%3E %3Cdestination URL%3E%22);%0A  console.log(%22Example: node push.js output.json %5C%22http://data-service.geocens.ca/...%5C%22%22);%0A  console.log(%22URL should point to record resource on Data Service.%22)%0A%7D;%0A%0Aif (process.argv.length !== 4) %7B%0A  console.log(%22Error! not enough arguments%22);%0A  usage();%0A  process.exit(1);%0A%7D
+argv = require('yargs')%0A  .usage('Usage: $0 %3Cinput records%3E %3Cdestination URL%3E')%0A  .demand(2)%0A  .argv
 ;%0A%0Av
@@ -226,22 +226,16 @@
 t = 
-process.argv%5B3
+argv._%5B1
 %5D;%0A%0A
@@ -249,22 +249,16 @@
 e = 
-process.argv%5B2
+argv._%5B0
 %5D;%0Af

Use yargs for push script