switchback
Advanced tools
Comparing version 0.0.1 to 0.2.0
@@ -5,2 +5,4 @@ #!/usr/bin/env node | ||
switchback.program('complex'); | ||
switchback.command('echo', { | ||
@@ -25,2 +27,2 @@ description: 'Echos your arguments', | ||
}) | ||
.exec(); | ||
.exec(); |
#!/usr/bin/env node | ||
var switchback = require('../lib/switchback'); | ||
var switchback = require('../lib/switchback').program('heroku'); | ||
@@ -5,0 +5,0 @@ function foo(name) { |
#!/usr/bin/env node | ||
var sys = require('sys') | ||
var util = require('util') | ||
, switchback = require('../lib/switchback'); | ||
@@ -12,4 +12,4 @@ | ||
method: function() { | ||
sys.puts(this.bar); | ||
util.puts(this.bar); | ||
} | ||
}).exec(); | ||
}).exec(); |
#!/usr/bin/env node | ||
var sys = require('sys') | ||
var util = require('util') | ||
, switchback = require('../lib/switchback'); | ||
switchback.command('echo', function() { | ||
sys.puts(Array.prototype.slice.call(arguments, 0).join(' ')); | ||
}).exec(); | ||
util.puts(Array.prototype.slice.call(arguments, 0).join(' ')); | ||
}).exec(); |
@@ -1,2 +0,2 @@ | ||
var sys = require('sys') | ||
var util = require('util') | ||
, path = require('path'); | ||
@@ -39,2 +39,7 @@ | ||
Switchback.prototype.program = function(program) { | ||
this.context.program = program; | ||
return this; | ||
}; | ||
Switchback.prototype.describe = function(description) { | ||
@@ -82,3 +87,3 @@ this.structure._description = description; | ||
Switchback.prototype.print_help_structure = function(structure, prefix) { | ||
sys.puts(''); | ||
util.puts(''); | ||
@@ -88,10 +93,10 @@ Object.keys(structure).filter(function(item) { | ||
}).forEach(function(topic) { | ||
sys.puts(' ' + (prefix ? prefix + ' ' : '') + pad(topic, 16) + structure[topic]._description); | ||
util.puts(' ' + (prefix ? prefix + ' ' : '') + pad(topic, 16) + structure[topic]._description); | ||
}); | ||
sys.puts(''); | ||
util.puts(''); | ||
}; | ||
Switchback.prototype.help_topic = function(topic) { | ||
sys.puts('Additional commands, type "heroku help COMMAND" for more details:'); | ||
util.puts('Additional commands, type "' + this.context.program + ' help COMMAND" for more details:'); | ||
this.print_help_structure(this.structure[topic], topic); | ||
@@ -105,5 +110,5 @@ }; | ||
sys.puts('Usage: ' + this.context.program + ' COMMAND [options]'); | ||
sys.puts(''); | ||
sys.puts('Primary help topics, type "' + this.context.program + ' help TOPIC" for more details:'); | ||
util.puts('Usage: ' + this.context.program + ' COMMAND [options]'); | ||
util.puts(''); | ||
util.puts('Primary help topics, type "' + this.context.program + ' help TOPIC" for more details:'); | ||
this.print_help_structure(this.structure); | ||
@@ -120,2 +125,3 @@ }; | ||
} | ||
if (!a._method) { return self.help(); } | ||
return a._method.apply(a._scope, args); | ||
@@ -122,0 +128,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"description": "Command-line library for apps like heroku and jitsu", | ||
"version": "0.0.1", | ||
"version": "0.2.0", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "type": "git", |
@@ -14,7 +14,7 @@ # Installation | ||
```javascript | ||
var sys = require('sys') | ||
var util = require('util') | ||
, switchback = require('switchback'); | ||
switchback.command('echo', function() { | ||
sys.puts(Array.prototype.slice.call(arguments, 0).join(' ')); | ||
util.puts(Array.prototype.slice.call(arguments, 0).join(' ')); | ||
}).exec(); | ||
@@ -29,3 +29,3 @@ ``` | ||
method: function() { | ||
sys.puts(Array.prototype.slice.call(arguments, 0).join(' ')); | ||
util.puts(Array.prototype.slice.call(arguments, 0).join(' ')); | ||
} | ||
@@ -44,3 +44,3 @@ }).exec(); | ||
method: function() { | ||
sys.puts(this.bar); | ||
util.puts(this.bar); | ||
} | ||
@@ -47,0 +47,0 @@ }).exec(); |
7360
201