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
44
45
46
|
# File 'lib/boot.rb', line 7
def self.main
default_config_file_path = File.dirname(__FILE__) + '/boot-default-config.json'
default_config_object = JSON.parse(File.open(default_config_file_path, "rb").read)
dot_config_file_path = File.expand_path('~/.boot')
dot_config_object = {}
if (File.exists?(dot_config_file_path))
dot_config_file = File.open(dot_config_file_path, "rb")
dot_config_object = JSON.parse(dot_config_file.read)
end
config_object = default_config_object.merge(dot_config_object)
begin
@config = Boot::Lib::Core::Config.new(config_object)
rescue Boot::Lib::Core::InvalidConfigException => e
puts e.message
exit
end
@sub_commands = {}
@sub_commands['help'] = Boot::Lib::Commands::Help
@sub_commands['new'] = Boot::Lib::Commands::New
@sub_commands['config'] = Boot::Lib::Commands::Config
@sub_commands['version'] = Boot::Lib::Commands::Version
@sub_commands['template'] = Boot::Lib::Commands::Template
if ARGV[0] == nil
Boot::Lib::Commands::Help.run([]);
elsif @sub_commands[ARGV[0]].nil?
puts "'#{ARGV[0]}' is not a sub command. See 'boot help'"
else
subCmdObj = @sub_commands[ARGV[0].downcase]
ARGV.shift; subCmdObj.run(ARGV)
end
end
|