Skip to content
This repository has been archived by the owner on Apr 23, 2021. It is now read-only.

Commit

Permalink
Command status finished
Browse files Browse the repository at this point in the history
  • Loading branch information
pksunkara committed Apr 1, 2012
1 parent ac1d726 commit 16387ef
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 10 deletions.
28 changes: 19 additions & 9 deletions README.md
Expand Up @@ -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, {
Expand All @@ -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.
Expand Down
30 changes: 29 additions & 1 deletion index.js
Expand Up @@ -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);
}
});
};

};

0 comments on commit 16387ef

Please sign in to comment.