Permalink
Browse files

update for node 0.8

  • Loading branch information...
crcn committed Nov 13, 2012
1 parent 4f68e18 commit 7341327971dabfd7a37d3dd8c3a81579204f0955
Showing with 1,439 additions and 7,747 deletions.
  1. +1 −3 .gitignore
  2. +31 −24 lib/index.js
  3. +0 −2 lib/plugins/argv/index.js
  4. +0 −1 lib/plugins/auth.js
  5. +17 −20 lib/plugins/backspace.js
  6. +7 −4 lib/plugins/command.api.js
  7. +4 −9 lib/plugins/command.js
  8. +2 −0 lib/plugins/command.route.js
  9. +17 −20 lib/plugins/enter.js
  10. +14 −25 lib/plugins/help.js
  11. +26 −29 lib/plugins/history.js
  12. +15 −18 lib/plugins/nav.js
  13. +6 −9 lib/plugins/quit.js
  14. +0 −1 node_modules/beanpole
  15. +0 −1 node_modules/beanpoll
  16. 0 node_modules/colors/MIT-LICENSE.txt
  17. +5 −5 node_modules/colors/ReadMe.md
  18. 0 node_modules/colors/colors.js
  19. 0 node_modules/colors/example.html
  20. 0 node_modules/colors/example.js
  21. +18 −12 node_modules/colors/package.json
  22. +1 −1 node_modules/crema/.cupboard
  23. +0 −1 node_modules/crema/.gitignore
  24. +6 −0 node_modules/crema/examples/index.js
  25. +101 −31 node_modules/crema/lib/index.js
  26. +14 −11 node_modules/crema/package.json
  27. +0 −23 node_modules/crema/project.sublime-project
  28. +127 −25 node_modules/crema/project.sublime-workspace
  29. +0 −50 node_modules/crema/src/grammar.peg
  30. +10 −4 node_modules/disposable/package.json
  31. +0 −1 node_modules/haba
  32. +0 −1 node_modules/outcome/.gitignore
  33. +5 −0 node_modules/outcome/lib/index.js
  34. +103 −77 node_modules/outcome/outcome.js
  35. +15 −17 node_modules/outcome/outcome.min.js
  36. +9 −7 node_modules/outcome/package.json
  37. +94 −58 node_modules/outcome/project.sublime-workspace
  38. +0 −7 node_modules/plugin/.cupboard
  39. +0 −2 node_modules/plugin/.gitignore
  40. +0 −299 node_modules/plugin/README.md
  41. +0 −7 node_modules/plugin/examples/test1/index.js
  42. +0 −16 node_modules/plugin/examples/test1/plugins/hello1.js
  43. +0 −7 node_modules/plugin/examples/test1/plugins/hello2.js
  44. +0 −9 node_modules/plugin/examples/test2/api/users/index.js
  45. +0 −15 node_modules/plugin/examples/test2/api/users/photos/index.js
  46. +0 −4 node_modules/plugin/examples/test2/index.js
  47. +0 −149 node_modules/plugin/lib/node/collection.js
  48. +0 −544 node_modules/plugin/lib/node/core.js
  49. +0 −15 node_modules/plugin/lib/node/fs.js
  50. +0 −195 node_modules/plugin/lib/node/index.js
  51. +0 −10 node_modules/plugin/lib/node/loaders/beanpoll.js
  52. +0 −10 node_modules/plugin/lib/node/loaders/hookio.js
  53. +0 −16 node_modules/plugin/lib/node/loaders/now.js
  54. +0 −27 node_modules/plugin/lib/node/nameTester.js
  55. +0 −3 node_modules/plugin/lib/node/package.json
  56. +0 −20 node_modules/plugin/lib/node/plugins/authorize.js
  57. +0 −24 node_modules/plugin/lib/node/plugins/hooks.js
  58. +0 −6 node_modules/plugin/lib/node/web.js
  59. +0 −149 node_modules/plugin/lib/web/collection.js
  60. +0 −544 node_modules/plugin/lib/web/core.js
  61. +0 −35 node_modules/plugin/lib/web/fs.js
  62. +0 −195 node_modules/plugin/lib/web/index.js
  63. +0 −10 node_modules/plugin/lib/web/loaders/beanpoll.js
  64. +0 −10 node_modules/plugin/lib/web/loaders/hookio.js
  65. +0 −16 node_modules/plugin/lib/web/loaders/now.js
  66. +0 −27 node_modules/plugin/lib/web/nameTester.js
  67. +0 −21 node_modules/plugin/lib/web/package.json
  68. +0 −20 node_modules/plugin/lib/web/plugins/authorize.js
  69. +0 −24 node_modules/plugin/lib/web/plugins/hooks.js
  70. +0 −6 node_modules/plugin/lib/web/web.js
  71. +0 −21 node_modules/plugin/package.json
  72. +0 −23 node_modules/plugin/project.sublime-project
  73. +0 −2,548 node_modules/plugin/project.sublime-workspace
  74. +0 −149 node_modules/plugin/src/common/collection.js
  75. +0 −544 node_modules/plugin/src/common/core.js
  76. +0 −195 node_modules/plugin/src/common/index.js
  77. +0 −10 node_modules/plugin/src/common/loaders/beanpoll.js
  78. +0 −10 node_modules/plugin/src/common/loaders/hookio.js
  79. +0 −16 node_modules/plugin/src/common/loaders/now.js
  80. +0 −27 node_modules/plugin/src/common/nameTester.js
  81. +0 −3 node_modules/plugin/src/common/package.json
  82. +0 −20 node_modules/plugin/src/common/plugins/authorize.js
  83. +0 −24 node_modules/plugin/src/common/plugins/hooks.js
  84. +0 −6 node_modules/plugin/src/common/web.js
  85. +0 −15 node_modules/plugin/src/node/fs.js
  86. +0 −35 node_modules/plugin/src/web/fs.js
  87. 0 node_modules/structr/.cupboard
  88. +0 −3 node_modules/structr/.gitignore
  89. 0 node_modules/structr/MIT-LICENSE.txt
  90. +249 −87 node_modules/structr/README.md
  91. 0 node_modules/structr/examples/abstractFinal.js
  92. 0 node_modules/structr/examples/events.html
  93. 0 node_modules/structr/examples/events.js
  94. 0 node_modules/structr/examples/node.test.js
  95. 0 node_modules/structr/examples/overloading.html
  96. +3 −1 node_modules/structr/examples/overloading.js
  97. +23 −5 node_modules/structr/examples/proto.js
  98. 0 node_modules/structr/examples/static.js
  99. 0 node_modules/structr/examples/wrapAround.js
  100. +352 −218 node_modules/structr/lib/index.js
  101. +0 −1 node_modules/structr/lib/web/package.json
  102. +16 −10 node_modules/structr/package.json
  103. 0 node_modules/structr/project.sublime-project
  104. +98 −282 node_modules/structr/project.sublime-workspace
  105. 0 node_modules/structr/project.tmproj
  106. +0 −3 node_modules/tq/.cupboard
  107. +0 −60 node_modules/tq/README.md
  108. +0 −110 node_modules/tq/lib/index.js
  109. +0 −10 node_modules/tq/package.json
  110. +0 −23 node_modules/tq/project.sublime-project
  111. +0 −322 node_modules/tq/project.sublime-workspace
  112. +0 −1 node_modules/underscore/.gitignore
  113. +25 −9 node_modules/underscore/package.json
  114. +25 −24 package.json
View
@@ -1,3 +1 @@
-node_modulesnode_modules
-
-
+node_modules
View
@@ -1,8 +1,11 @@
var tty = require('tty'),
fs = require('fs'),
_buffer = '',
-haba = require('plugin').loader();
-require("colors")
+plugin = require("plugin");
+
+require("colors");
+
+require("keypress")(process.stdin);
exports.utils = require('./utils');
@@ -75,6 +78,8 @@ exports.buffer = function(value, ignoreReplace) {
exports.replaceLine = function(buffer, cursorTo) {
+ if(!buffer) buffer = "";
+
//need to clear the line before replacing it
process.stdout.clearLine();
@@ -129,19 +134,13 @@ exports.cursor = function(position) {
function stringRep(key) {
- var chain = '';
-
- for(var prop in key) {
- if(!key[prop]) continue;
-
- if(key[prop] == true) {
- chain = prop+'-'+chain;
- } else {
- chain += key.name;
- }
- }
-
- return chain;
+ var chain = [key.name];
+
+ if(key.shift) chain.unshift("shift-");
+ if(key.ctrl) chain.unshift("ctrl-");
+ if(key.meta) chain.unshift("meta-");
+
+ return chain.join("")
}
exports.write = function(string) {
@@ -165,17 +164,19 @@ exports.open = function(ops) {
stdin = process.openStdin();
stdin.setEncoding('utf8');
- tty.setRawMode(true);
+ process.stdin.setRawMode(true);
stdin.on('keypress', function(c, key) {
-
+
//integer?
- if(!key) key = { name: c.toString() }
-
+ if(!key) key = { name: c.toString() };
+ if(!c) c = key.name;
+
var chain = stringRep(key);
+
var emitSuccess = chain.length > 1 ? exports.emit(chain) : false;
@@ -198,7 +199,7 @@ exports.open = function(ops) {
//exports.insertText(exports.inputPrefix(), _cursorPosition);
//exports.cursor(0);
}
-
+
//for custom handlers: password, confirm, etc.
exports.emit('keypress', { char: c, key: key });
@@ -245,8 +246,7 @@ exports.parse = function(args, callback) {
var cmd = { command: command, data: data };
-
- haba.next(function() {
+ exports.next(function() {
if(!self.emit(command, data)) {
@@ -268,7 +268,14 @@ exports.parse = function(args, callback) {
return cmd;
}
-
-haba.options(exports, true).require(__dirname + '/plugins').init();
+plugin(exports).
+params({}).
+require(__dirname + "/plugins").
+load(function(err) {
+ if(err) {
+ console.error(err.stack);
+ process.exit();
+ }
+});
@@ -1,5 +1,3 @@
-exports.require = 'help'
-
exports.plugin = function(cli) {
View
@@ -1,4 +1,3 @@
-exports.require = 'prompt'
exports.plugin = function(cli) {
View
@@ -1,23 +1,20 @@
-exports.plugin = function(cli) {
+exports.require = ["command.route"];
+exports.plugin = function(commandRoute, cli) {
- return {
- init: function() {
- cli.onCommand('backspace', function() {
- var pos = cli.cursor();
- // console.log(pos)
- if(pos == cli.inputPrefix().length) return;
-
- cli.spliceLine(pos-1, 1, pos-1);
- //cli.replaceLine(buffer.substr(0, pos-1) + buffer.substr(pos, buffer.length-pos), pos-1);
-
- });
-
- cli.onCommand('delete', function() {
- var pos = cli.cursor();
-
- cli.spliceLine(pos, 1, pos);
- });
- }
- }
+ cli.onCommand('backspace', function() {
+ var pos = cli.cursor();
+ // console.log(pos)
+ if(pos == cli.inputPrefix().length) return;
+
+ cli.spliceLine(pos-1, 1, pos-1);
+ //cli.replaceLine(buffer.substr(0, pos-1) + buffer.substr(pos, buffer.length-pos), pos-1);
+
+ });
+
+ cli.onCommand('delete', function() {
+ var pos = cli.cursor();
+
+ cli.spliceLine(pos, 1, pos);
+ });
}
View
@@ -1,5 +1,7 @@
-var Structr = require('structr');
+var Structr = require('structr'),
+_ = require("underscore");
+exports.name = "command.api";
exports.plugin = function(cli) {
var target = {};
@@ -74,8 +76,9 @@ exports.plugin = function(cli) {
flattenMethods(normalizeApi(Structr.copy(api)), []).forEach(function(cmd) {
cli.addHelp(cmd);
});
-
- Structr.copy(demormalizeApi(api), target);
+ // console.log(demormalizeApi(api).cli.toString())
+ // Structr.copy(demormalizeApi(api), target);
+ _.extend(target, api);
}
return {
@@ -87,7 +90,7 @@ exports.plugin = function(cli) {
try {
var ret = eval("with(target) " + buffer);
- if(ret != undefined) console.log(ret)
+ if(ret != undefined) console.log(ret);
return true;
} catch(e) {
console.log('\nUnable to call %s \n%s', buffer.bold, e.message.red.bold);
View
@@ -1,13 +1,13 @@
var tq = require('tq');
-exports.plugin = function(cli) {
+exports.plugin = function(cli, loader) {
var queue = tq.queue(), handlers = [];
function getHandler(type) {
- handlers = haba.plugins(/command\.\w+/);
+ handlers = loader.modules("command.*");
for(var i = handlers.length; i--;) {
var handler = handlers[i];
@@ -25,16 +25,11 @@ exports.plugin = function(cli) {
return handler.run(buffer, data);
} catch(e) {
- console.error(e.stack)
+ console.error(e.stack);
return false;
}
}
- var haba = this;
- return {
- init: function() {
- queue.start();
- }
- }
+ queue.start();
}
@@ -54,6 +54,8 @@ var CmdDirector = Structr(beanpoll.Director, {
});
+exports.name = "command.route";
+
exports.plugin = function(cli) {
View
@@ -1,4 +1,5 @@
-exports.plugin = function(cli) {
+exports.require = ["command.route"];
+exports.plugin = function(commandRoute, cli) {
cli.run = function(buffer) {
@@ -29,29 +30,25 @@ exports.plugin = function(cli) {
}
- return {
- init: function() {
- cli.onCommand('enter', function() {
+ cli.onCommand('enter', function() {
- var failed = false;
+ var failed = false;
- var commands = cli.buffer().replace(cli.inputPrefix(),'').split(';'),
- running = commands.length;
+ var commands = cli.buffer().replace(cli.inputPrefix(),'').split(';'),
+ running = commands.length;
- commands.forEach(function(command) {
- process.nextTick(function() {
- cli.emit(command, null, function(success) {
- failed = !success || failed;
+ commands.forEach(function(command) {
+ process.nextTick(function() {
+ cli.emit(command, null, function(success) {
+ failed = !success || failed;
- if(!(--running) && failed) {
- process.nextTick(cli.help);
- }
- })
- })
- });
+ if(!(--running) && failed) {
+ process.nextTick(cli.help);
+ }
+ })
+ })
+ });
- });
- }
- }
+ });
}
View
@@ -158,29 +158,18 @@ exports.plugin = function(cli) {
next();
}
- return {
- init: function() {
-
- cli.option('help', cli.help).
- option(':command help OR **', cli.commandHelp);
-
- cli.addHelp({
- category: 'help',
- name: '[cmd] help',
- description: 'Show command help menu'
- });
-
- cli.addHelp({
- category: 'help',
- name: 'help',
- description: 'Show help menu'
- });
-
-
- }
- }
- /*cli.on('help', function()
- {
- cli.help();
- });*/
+ cli.option('help', cli.help).
+ option(':command help OR **', cli.commandHelp);
+
+ cli.addHelp({
+ category: 'help',
+ name: '[cmd] help',
+ description: 'Show command help menu'
+ });
+
+ cli.addHelp({
+ category: 'help',
+ name: 'help',
+ description: 'Show help menu'
+ });
}
Oops, something went wrong.

0 comments on commit 7341327

Please sign in to comment.