/
configure.rb
executable file
·45 lines (39 loc) · 943 Bytes
/
configure.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
44
45
#!/usr/bin/env ruby
require 'bundler/setup'
require 'main'
def autoload_all(path)
Dir.glob("#{path}**/*.rb").each do |file|
File.open(file, 'r') do |infile|
while (line = infile.gets)
match = line.match(/^(class|module)\s([A-Z]\w+)/)
if !match.nil? && !match[2].nil?
autoload match[2].to_sym, File.expand_path(file)
break
end
end
end
end
end
autoload_all 'app/'
Main do
option(:username) do
argument :optional
description 'Set the username'
end
option(:password) do
argument :optional
description 'Set the password'
end
option(:app_key) do
argument :optional
description 'Set the path to the application key'
end
def run
updated = params.select(&:given?)
updated = updated.each_with_object({}) do |param, result|
result[param.name.to_sym] = param.value
result
end
ConfigService.update updated
end
end