-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsole.rb
43 lines (34 loc) · 920 Bytes
/
console.rb
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
38
39
40
41
42
43
working_dir = File.dirname(__FILE__)
Dir.chdir(working_dir)
require 'pp'
require './parameters'
require $neo_dir+'/neo'
Neo.app_dir = '.'
Neo.dir = $neo_dir
Neo.init
raise 'You must give a command to execute --' if ARGV[0].nil?
module_name, command_name = ARGV[0].split(':')
commands = {}
if module_name != 'neo'
Dir[Neo.app_dir+'/modules/'+module_name+'/commands/*'].each do |f|
commands[f.split('/')[-1].gsub('.rb','')] = f
end
else
Dir[Neo.dir+'/commands/*'].each do |f|
commands[f.split('/')[-1].gsub('.rb','')] = f
end
end
Neo::Config.main[:env] = 'dev'
if commands.key?command_name
require commands[command_name]
params = nil
params = ARGV[1..-1] if ARGV.length>1
console_class = eval(module_name.camelize+'::Commands::'+command_name.camelize+'.new')
if params.nil?
console_class.send('run')
else
console_class.send('run', *params)
end
else
pp 'Command Not Found: '+ARGV[0]
end