Permalink
Browse files

[minor refactor] Update to use `flatiron.common.templateUsage` now th…

…at it has been hoisted into `flatiron/flatiron`
  • Loading branch information...
1 parent d26c99b commit 1f9a6e575709b0f26a9f4816e72b1b8111a151b8 @indexzero indexzero committed Feb 13, 2012
Showing with 3 additions and 29 deletions.
  1. +3 −29 lib/flatiron-cli-config.js
View
@@ -5,7 +5,7 @@
*
*/
-var utile = require('flatiron').common;
+var common = require('flatiron').common;
var cliConfig = exports;
@@ -36,10 +36,10 @@ cliConfig.attach = function (options) {
cliConfig.store = options.store || null;
cliConfig.restricted = options.restricted || [];
cliConfig.before = options.before || {};
- cliConfig.setUsage();
+ common.templateUsage(app, cliConfig.commands);
app.commands['config'] = app.commands['config'] || {};
- app.commands['config'] = utile.mixin(app.commands['config'], cliConfig.commands);
+ app.commands['config'] = common.mixin(app.commands['config'], cliConfig.commands);
app.alias('conf', { resource: 'config', command: 'list' });
};
@@ -57,30 +57,4 @@ cliConfig.detach = function () {
cliConfig.commands.app = null;
});
-};
-
-//
-// ### function setUsage ()
-// Updates the command usage for the `<app>` this instance
-// is attached to.
-//
-cliConfig.setUsage = function () {
- if (!cliConfig.app.name) {
- return;
- }
-
- function templateUsage(usage) {
- return usage.map(function (line) {
- return line.replace(/\<app\>/ig, cliConfig.app.name);
- });
- }
-
- Object.keys(cliConfig.commands).forEach(function (command) {
- if (command === 'usage') {
- cliConfig.commands.usage = templateUsage(cliConfig.commands.usage)
- }
- else if (cliConfig.commands[command].usage) {
- cliConfig.commands[command].usage = templateUsage(cliConfig.commands[command].usage)
- }
- });
};

0 comments on commit 1f9a6e5

Please sign in to comment.