Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Command status finished

  • Loading branch information...
commit 16387efb3981f77144675e1dc6488826e3cfcc5b 1 parent ac1d726
@pksunkara authored
Showing with 48 additions and 10 deletions.
  1. +19 −9 README.md
  2. +29 −1 index.js
View
28 README.md
@@ -13,10 +13,6 @@ At its core `flatiron-cli-ok` is a broadway-compatible plugin which can be used
var flatiron = require('flatiron')
, app = flatiron.app;
-//
-// Configure the Application to be a CLI app with
-// a JSON configuration file `test-config.json`
-//
app.name = 'app.js';
app.use(flatiron.plugins.cli, {
@@ -25,20 +21,34 @@ app.use(flatiron.plugins.cli, {
app.use(require('flatiron-cli-ok'));
-if (!module.parent) {
- app.start();
-}
+app.start();
```
If you run the above script
```bash
-$ node app.js
+ node app.js
```
-The output will be
+The output will start with
```bash
+info: Welcome to app.js
+info: It worked if it ends with app.js ok
+```
+
+and ends with
+
+* If the command executed successfully
+
+```bash
+info: app.js ok
+```
+
+* If the command executed unsuccessfully
+
+```bash
+info: app.js not ok
```
If you like this project, please watch this and [follow](http://github.com/users/follow?target=pksunkara) me.
View
30 index.js
@@ -12,10 +12,38 @@ var cliOk = exports = module.exports;
cliOk.name = 'cli-ok';
cliOk.attach = function (options) {
- var app = this;
+ var app = this, logger;
options = options || {};
if (!app.plugins.cli) {
throw new Error('`cli` plugin is required to use `flatiron-cli-ok`');
}
+
+ var start = app.start;
+ // var init = app.init;
+
+ // app.init = function (options, cb) {
+ // init(options || {}, function (err) {
+ // app.log.info('Welcome to ' + app.name.grey);
+ // app.log.info('It worked if it ends with ' + app.name.grey + ' ok'.green.bold);
+ // cb(err);
+ // });
+ // };
+
+ app.start = function (options, cb) {
+ if (!cb && typeof options == 'function') {
+ cb = options;
+ options = null;
+ }
+
+ start(options || {}, function (err) {
+ if (cb) return cb(err);
+ if (err) {
+ app.log.info(app.name.grey + ' ' + 'not ok'.red.bold);
+ } else {
+ app.log.info(app.name.grey + ' ' + 'ok'.green.bold);
+ }
+ });
+ };
+
};
Please sign in to comment.
Something went wrong with that request. Please try again.