-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 672c7d0
Showing
17 changed files
with
619 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
node_modules | ||
*.sock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
support | ||
test | ||
examples | ||
*.sock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
0.0.1 / 2010-01-03 | ||
================== | ||
|
||
* Initial release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
TESTS = $(shell find test/test.*.js) | ||
|
||
test: | ||
@./test/run $(TESTS) | ||
|
||
.PHONY: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
# commander | ||
|
||
the complete solution for node.js command-line programs | ||
|
||
## License | ||
|
||
(The MIT License) | ||
|
||
Copyright (c) 2011 TJ Holowaychuk <[email protected]> | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
'Software'), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY | ||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, | ||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var program = require('../'); | ||
|
||
function range(val) { | ||
return val.split('..').map(Number); | ||
} | ||
|
||
function list(val) { | ||
return val.split(','); | ||
} | ||
|
||
program | ||
.version('0.0.1') | ||
.description('Pizza configurator') | ||
.option('-i, --integer <n>', 'An integer argument', parseInt) | ||
.option('-f, --float <n>', 'A float argument', parseFloat) | ||
.option('-r, --range <a>..<b>', 'A range', range) | ||
.option('-l, --list <items>', 'A list', list) | ||
.option('-o, --optional [value]', 'An optional value') | ||
.parse(process.argv); | ||
|
||
console.log(' int: %j', program.integer); | ||
console.log(' float: %j', program.float); | ||
console.log(' optional: %j', program.optional); | ||
program.range = program.range || []; | ||
console.log(' range: %j..%j', program.range[0], program.range[1]); | ||
console.log(' list: %j', program.list); | ||
console.log(' args: %j', program.args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var program = require('../'); | ||
|
||
program | ||
.version('0.0.1') | ||
.description('application deployer') | ||
.option('-C, --chdir <path>', 'change the working directory') | ||
.option('-c, --config <path>', 'set config path. defaults to ./deploy.conf') | ||
.option('-T, --no-tests', 'ignore test hook') | ||
|
||
program | ||
.command('setup [env]') | ||
.description('run remote setup commands') | ||
.action(function(){ | ||
console.log('setup'); | ||
}); | ||
|
||
program | ||
.command('exec <cmd>') | ||
.description('run the given remote command') | ||
.action(function(cmd){ | ||
console.log('exec "%s"', cmd); | ||
}); | ||
|
||
program | ||
.command('*') | ||
.description('deploy the given env') | ||
.action(function(env){ | ||
console.log('deploying "%s"', env); | ||
}); | ||
|
||
program.parse(process.argv); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var program = require('../'); | ||
|
||
program | ||
.version('0.0.1') | ||
.description('Express application generator') | ||
.option('-s, --sessions', 'add session support') | ||
.option('-t, --template <engine>', 'specify template engine (jade|ejs) [jade]') | ||
.option('-c, --css <engine>', 'specify stylesheet engine (stylus|sass|less) [css]') | ||
.parse(process.argv); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var program = require('../'); | ||
|
||
// ask('bool?') | ||
// ask('Username: ') | ||
// ask('Password: ') | ||
// ask('Description:') | ||
// ask('Birthday: ', Date) | ||
// ask('Age: ', Number) | ||
// ask('Fav colors: ', Array) | ||
// askForArray('Fav colors: ') | ||
// choose(options) | ||
|
||
program.askForNumber = function(str, fn){ | ||
this.askSingleLine(str, function(val){ | ||
val = Number(val); | ||
if (isNaN(val)) return program.askForNumber(str + '(must be a number) ', fn); | ||
fn(val); | ||
}); | ||
}; | ||
|
||
program.askForDate = function(str, fn){ | ||
this.askSingleLine(str, function(val){ | ||
val = new Date(val); | ||
if (isNaN(val.getTime())) return program.askForDate(str + '(must be a date) ', fn); | ||
fn(val); | ||
}); | ||
}; | ||
|
||
program.askSingleLine = function(str, fn){ | ||
if ('function' == typeof arguments[2]) { | ||
return this['askFor' + (fn.name || fn)](str, arguments[2]); | ||
} | ||
|
||
process.stdout.write(str); | ||
process.stdin.setEncoding('utf8'); | ||
process.stdin.once('data', function(val){ | ||
fn(val); | ||
}).resume(); | ||
}; | ||
|
||
program.askMultiLine = function(str, fn){ | ||
var buf = ''; | ||
console.log(str); | ||
process.stdin.setEncoding('utf8'); | ||
process.stdin.on('data', function(val){ | ||
if ('\n' == val) { | ||
process.stdin.removeAllListeners('data'); | ||
fn(buf); | ||
} else { | ||
buf += val; | ||
} | ||
}).resume(); | ||
}; | ||
|
||
program.ask = function(str, fn){ | ||
if (/ $/.test(str)) return this.askSingleLine.apply(this, arguments); | ||
this.askMultiLine(str, fn); | ||
}; | ||
|
||
program.ask('Username: ', function(name){ | ||
console.log('hi %s', name); | ||
|
||
program.ask('Description:', function(desc){ | ||
console.log('description was "%s"', desc.trim()); | ||
|
||
program.ask('Age: ', Number, function(age){ | ||
console.log('age: %j', age); | ||
|
||
program.ask('Birthdate: ', Date, function(date){ | ||
console.log('date: %s', date); | ||
process.stdin.destroy(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env node | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var program = require('../'); | ||
|
||
program | ||
.version('0.0.1') | ||
.description('Pizza configurator') | ||
.option('-p, --peppers', 'Add peppers') | ||
.option('-P, --pineapple', 'Add pineappe') | ||
.option('-b, --bbq', 'Add bbq sauce') | ||
.option('-c, --cheese <type>', 'Add the specified type of cheese [cheddar]') | ||
.option('-C, --no-cheese', 'You do not want any cheese') | ||
.parse(process.argv); | ||
|
||
console.log('you ordered a pizza with:'); | ||
if (program.peppers) console.log(' - peppers'); | ||
if (program.pineappe) console.log(' - pineappe'); | ||
if (program.bbq) console.log(' - bbq'); | ||
|
||
var cheese = false === program.cheese | ||
? 'no' | ||
: program.cheese || 'cheddar'; | ||
|
||
console.log(' - %s cheese', cheese); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
module.exports = require('./lib/commander'); |
Oops, something went wrong.