sarnesjo-twhere 0.0.9 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +1 -1
- data/bin/twhere +46 -8
- metadata +1 -1
data/VERSION.yml
CHANGED
data/bin/twhere
CHANGED
@@ -6,28 +6,66 @@ require 'optparse'
|
|
6
6
|
|
7
7
|
config_file = nil
|
8
8
|
|
9
|
-
OptionParser.new do |
|
10
|
-
|
9
|
+
opts = OptionParser.new do |o|
|
10
|
+
o.banner = 'usage: twhere [options]'
|
11
11
|
|
12
|
-
|
12
|
+
o.on('-c', '--config FILE', 'specify config file') do |c|
|
13
13
|
config_file = c
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
puts
|
16
|
+
o.on_tail('-h', '--help', 'show this message') do
|
17
|
+
$stderr.puts o
|
18
18
|
exit
|
19
19
|
end
|
20
20
|
|
21
|
-
|
21
|
+
o.on_tail('-V', '--version', 'show version') do
|
22
22
|
version = YAML::load(File.open(File.join(File.dirname(__FILE__), '..', 'VERSION.yml')))
|
23
|
-
puts "#{version[:major]}.#{version[:minor]}.#{version[:patch]}"
|
23
|
+
$stderr.puts "#{version[:major]}.#{version[:minor]}.#{version[:patch]}"
|
24
24
|
exit
|
25
25
|
end
|
26
|
-
end
|
26
|
+
end
|
27
|
+
|
28
|
+
opts.parse!
|
29
|
+
|
30
|
+
# make sure the config option was given
|
31
|
+
unless config_file
|
32
|
+
$stderr.puts opts
|
33
|
+
exit 1
|
34
|
+
end
|
27
35
|
|
28
36
|
# load config
|
29
37
|
config = YAML::load(File.open(config_file))
|
30
38
|
|
39
|
+
# make sure config was properly loaded
|
40
|
+
unless config
|
41
|
+
$stderr.puts "could not load config from #{config_file}"
|
42
|
+
exit 1
|
43
|
+
end
|
44
|
+
|
45
|
+
# make sure these keys are set
|
46
|
+
[:twhere, :twitter].each do |key|
|
47
|
+
unless config[key]
|
48
|
+
$stderr.puts "could not find :#{key} in config"
|
49
|
+
exit 1
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# make sure these keys are set
|
54
|
+
[:locations_file, :template_file].each do |key|
|
55
|
+
unless config[:twhere][key]
|
56
|
+
$stderr.puts "could not find :#{key} in config"
|
57
|
+
exit 1
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# make sure these keys are set
|
62
|
+
[:username, :password].each do |key|
|
63
|
+
unless config[:twitter][key]
|
64
|
+
$stderr.puts "could not find :#{key} in config"
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
31
69
|
# load known locations
|
32
70
|
locations = YAML::load(File.open(config[:twhere][:locations_file]))
|
33
71
|
|