1 |
|
2 |
|
3 |
|
4 |
|
5 | var pkg = require('./package.json')
|
6 | , fs = require('fs')
|
7 | , path = require('path')
|
8 | , nash = require('nash')
|
9 | , cli = nash()
|
10 | ;
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | cli.set({
|
18 | pkg:
|
19 | pkg,
|
20 | logo:
|
21 | fs.readFileSync(
|
22 | path.join(__dirname, 'lib', 'logo.txt'), 'ascii'
|
23 | ),
|
24 | website:
|
25 | 'http://anvil.io',
|
26 | description:
|
27 | 'A modern authorization server built to\n' +
|
28 | 'authenticate your users and protect your APIs.',
|
29 | });
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 |
|
37 | cli.initialize = function (directory) {
|
38 | var plugins = []
|
39 | , modules = fs.readdirSync(directory)
|
40 | ;
|
41 |
|
42 | modules.forEach(function (mod) {
|
43 | if (path.extname(mod) === '.js' && path.basename(mod) !== 'index.js') {
|
44 | plugins.push({
|
45 | register: require(path.join(directory, mod))
|
46 | });
|
47 | }
|
48 | });
|
49 |
|
50 | cli.register(plugins, function (err) {});
|
51 | }
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | cli.initialize(path.join(__dirname, 'lib', 'commands'));
|
59 | cli.initialize(path.join(__dirname, 'lib', 'plugins'));
|
60 |
|
61 |
|
62 |
|
63 |
|
64 |
|
65 |
|
66 | module.exports = cli;
|