Skip to content
Browse files

FIX cli.js

  • Loading branch information...
1 parent 3160e3f commit b48021d9163a35f334c5e583d187249ccc550ca4 @naholyr committed Aug 3, 2011
Showing with 28 additions and 27 deletions.
  1. +28 −27 cli.js
View
55 cli.js
@@ -1,7 +1,5 @@
//#!/usr/bin/env node
-require.paths.push('./src', './node_modules');
-
process.chdir(__dirname);
var conf = require('node-config');
@@ -13,34 +11,37 @@ conf.initConfig(function(err) {
process.exit(1);
}
- provider = require('url-provider').get(conf.url_provider, conf[conf.url_provider]);
- provider.open(function(err) {
+ require('./lib/url-provider').load(conf.url_provider, conf[conf.url_provider], function (err, provider) {
if (err) {
throw err;
}
-
- switch (process.argv[2]) {
- case 'encode':
- provider.encode(process.argv[3], process.argv[4], function(err, key) {
- if (err) {
- throw err;
- }
- process.stdout.write(key + "\n");
- provider.close();
- });
- break;
- case 'decode':
- provider.decode(process.argv[3], function(err, url) {
- if (err) {
- throw err;
- }
- process.stdout.write(url + "\n");
- provider.close();
- });
- break;
- default:
- throw "Unknown command, use 'encode' or 'decode'";
- }
+ provider.open(function(err) {
+ if (err) {
+ throw err;
+ }
+ switch (process.argv[2]) {
+ case 'encode':
+ provider.encode(process.argv[3], process.argv[4], function(err, key) {
+ if (err) {
+ throw err;
+ }
+ process.stdout.write(key + "\n");
+ provider.close();
+ });
+ break;
+ case 'decode':
+ provider.decode(process.argv[3], function(err, url) {
+ if (err) {
+ throw err;
+ }
+ process.stdout.write(url + "\n");
+ provider.close();
+ });
+ break;
+ default:
+ throw "Unknown command, use 'encode' or 'decode'";
+ }
+ });
});
});

0 comments on commit b48021d

Please sign in to comment.
Something went wrong with that request. Please try again.