Blame view

js/lib/JSBuilder/bin/Dispatch.js 1.06 KB
16035364   Benjamin Renard   First commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
var JSBuilderPath = system.cwd + '/lib/JSBuilder/';

load(JSBuilderPath + 'src/Loader.js');
Loader.setBasePath(JSBuilderPath + 'src');

Loader.require([
    'Ext', 'Cmd', 'Filesystem', 'Platform', 'Cli', 'Logger', 'Project', 'Target', 'Package', 'Build'
]);

/**
 * @class Ext.CommandDispatcher
 * @extends Object
 * Dispaches to the relevant Cli subclass from the command line 'sencha' command. e.g.
 * sencha generate xyz is dispatched to whichever Ext.Cli subclass registered itself to
 * handler the 'generate' command (Ext.generator.Factory in this case).
 */
Ext.CommandDispatcher = {
    types: {},
    
    dispatch: function(module, args) {
        new this.types[module]({args: args});
    }
};

Ext.regDispatchable = function(name, constructor) {
    Ext.CommandDispatcher.types[name] = constructor;
};

load('src/Generator.js');
load('src/generators/app/Application.js');
load('src/generators/controller/Controller.js');
load('src/generators/model/Model.js');

var args   = system.arguments,
    module = args[0];

Ext.CommandDispatcher.dispatch(module, args.slice(1));