Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 97 lines (64 sloc) 1.853 kB
ac1d726 @pksunkara Initial commit
authored
1 # flatiron-cli-ok
c356456 @pksunkara Better documentation
authored
2 Encapsulated logic for showing command status in flatiron CLI apps
ac1d726 @pksunkara Initial commit
authored
3
4 ## Installation
5 ```
6 npm install flatiron-cli-ok
7 ```
8
9 ## Usage
c356456 @pksunkara Better documentation
authored
10 At its core `flatiron-cli-ok` is a broadway-compatible plugin which can be used by any [flatiron](https://flatironjs.org) cli application
ac1d726 @pksunkara Initial commit
authored
11
12 ```js
13 var flatiron = require('flatiron')
14 , app = flatiron.app;
15
16 app.name = 'app.js';
17
18 app.use(flatiron.plugins.cli, {
19 usage: 'A simple CLI app using flatiron-cli-ok'
20 });
21
22 app.use(require('flatiron-cli-ok'));
23
16387ef @pksunkara Command status finished
authored
24 app.start();
ac1d726 @pksunkara Initial commit
authored
25 ```
26
27 If you run the above script
28
c356456 @pksunkara Better documentation
authored
29 ```
16387ef @pksunkara Command status finished
authored
30 ➤ node app.js
ac1d726 @pksunkara Initial commit
authored
31 ```
32
16387ef @pksunkara Command status finished
authored
33 The output will start with
ac1d726 @pksunkara Initial commit
authored
34
c356456 @pksunkara Better documentation
authored
35 ```
16387ef @pksunkara Command status finished
authored
36 info: Welcome to app.js
37 info: It worked if it ends with app.js ok
38 ```
39
c356456 @pksunkara Better documentation
authored
40 The output will end with
16387ef @pksunkara Command status finished
authored
41
42 * If the command executed successfully
43
c356456 @pksunkara Better documentation
authored
44 ```
16387ef @pksunkara Command status finished
authored
45 info: app.js ok
46 ```
47
48 * If the command executed unsuccessfully
49
c356456 @pksunkara Better documentation
authored
50 ```
16387ef @pksunkara Command status finished
authored
51 info: app.js not ok
ac1d726 @pksunkara Initial commit
authored
52 ```
53
7f6f7f0 @pksunkara Show error with option
authored
54 ### Show the error
55
56 You can give the `show` option to the plugin if you want to print the `err.message` passed to the callback
57
58 ```js
59 app.use('flatiron-cli-ok', { show: true });
60 ```
61
62 So in case of error, the output will end with
63
64 ```
65 error: Bad credentials
66 info: app.js not ok
67 ```
68
c356456 @pksunkara Better documentation
authored
69 ### IMPORTANT
70
71 __You have to call the callback in the command, if you want this plugin to show the status__
72
ac1d726 @pksunkara Initial commit
authored
73 If you like this project, please watch this and [follow](http://github.com/users/follow?target=pksunkara) me.
74
75 ## Testing
76 ```
77 npm test
78 ```
79
80 ## Contributors
81 Here is a list of [Contributors](http://github.com/pksunkara/flatiron-cli-ok/contributors)
82
83 ### TODO
84
85 __I accept pull requests and guarantee a reply back within a day__
86
87 ## License
88 MIT/X11
89
90 ## Bug Reports
91 Report [here](http://github.com/pksunkara/flatiron-cli-ok/issues). __Guaranteed reply within a day__.
92
93 ## Contact
94 Pavan Kumar Sunkara (pavan.sss1991@gmail.com)
95
96 Follow me on [github](http://github.com/pksunkara), [twitter](http://twitter.com/pksunkara)
Something went wrong with that request. Please try again.