1 | Controller = require '../lib/controller'
|
2 |
|
3 | {ConfigFile, KD_DIR, MODULE_ROOT, CURRENT_MODULE_ROOT, USER_MODULE_ROOT} = require '../lib/configFile'
|
4 |
|
5 | fs = require 'fs'
|
6 | path = require 'path'
|
7 |
|
8 | module.exports = class Kite extends Controller
|
9 |
|
10 | @set
|
11 | commands:
|
12 | 'help': ['help', 'Shows help']
|
13 | 'default': 'help'
|
14 |
|
15 | getModuleList: ->
|
16 | modulePaths = [MODULE_ROOT, USER_MODULE_ROOT, CURRENT_MODULE_ROOT]
|
17 |
|
18 | moduleFiles = []
|
19 | for modulePath in modulePaths when fs.existsSync modulePath
|
20 | for file in fs.readdirSync(modulePath)
|
21 | fpath = path.join(modulePath, file)
|
22 | if fpath not in moduleFiles
|
23 | moduleFiles.push(fpath)
|
24 | moduleFiles
|
25 |
|
26 | help: ->
|
27 | moduleList = @getModuleList()
|
28 | console.log """
|
29 | Usage:
|
30 |
|
31 | kd <module> <command> [arguments]
|
32 |
|
33 | The modules are:
|
34 |
|
35 | """
|
36 | console.log " " + (path.basename module.replace /.coffee$|.kdmodule$/, '' for module in moduleList when module.match /.coffee$|.kdmodule$/).join ", "
|
37 | console.log """
|
38 |
|
39 | Use "kd <module> help" for more information about that module.
|
40 | """
|
41 |
|