File tree 2 files changed +25
-9
lines changed
2 files changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -4,4 +4,4 @@ $LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
4
4
5
5
require 'xify'
6
6
7
- Xify . run ARGV
7
+ Xify . run
Original file line number Diff line number Diff line change 9
9
require 'xify/output/rocket_chat'
10
10
11
11
class Xify
12
- def self . run ( args )
12
+ @verbose = false
13
+
14
+ def self . run
13
15
working_dir = "#{ ENV [ 'HOME' ] } /.xify"
14
16
Dir . mkdir working_dir rescue Errno ::EEXIST
15
-
16
17
config_file = "#{ working_dir } /config.yml"
17
- if args . first == '-c'
18
- args . shift
19
- config_file = args . shift
18
+ files = [ ]
19
+
20
+ while arg = ARGV . shift do
21
+ case arg
22
+ when '-c' , '--config'
23
+ config_file = ARGV . shift
24
+ when '-v' , '--verbose'
25
+ @verbose = true
26
+ else
27
+ files << arg
28
+ end
20
29
end
21
30
22
- puts "Loading config from #{ config_file } "
31
+ ARGV . unshift ( *files )
32
+
33
+ debug "Loading config from #{ config_file } "
23
34
config = YAML ::load_file config_file
24
35
25
36
config . keys . each do |section |
26
- ns = section [ 0 ...-1 ] . capitalize
37
+ type = section [ 0 ...-1 ]
27
38
config [ section ] . map! do |handler |
28
39
next unless handler [ 'enabled' ]
29
- Object . const_get ( "#{ ns } ::#{ handler [ 'class' ] } " ) . new handler
40
+ debug "Setting up #{ handler [ 'class' ] } as #{ type } "
41
+ Object . const_get ( "#{ type . capitalize } ::#{ handler [ 'class' ] } " ) . new handler
30
42
end . compact!
31
43
end
32
44
@@ -44,4 +56,8 @@ def self.run(args)
44
56
45
57
Rufus ::Scheduler . singleton . join
46
58
end
59
+
60
+ def self . debug ( str )
61
+ puts str if @verbose
62
+ end
47
63
end
You can’t perform that action at this time.
0 commit comments