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
46
47
48
49
50
51
52
53
54
|
# File 'lib/salmon/config.rb', line 5
def self.parse_options(args)
options = OpenStruct.new
path = File.expand_path('~/.salmon')
abort("Please create a YAML server config file at ~/.salmon") if not File.readable?(path)
githubs = YAML.load(File.read(path))
options.temp_path = 'salmon'
options.push_tags = true
options.push_branches = ['*']
options.verbose = true
OptionParser.new do |opts|
opts.banner = "Usage: salmon [options]"
opts.separator ""
opts.separator "Available sites:"
opts.separator githubs.keys.join(", ")
opts.separator ""
opts.on("-s", "--source [SITE:ACCOUNT]", "Site name or source:destination string. Available: #{githubs.keys.join(', ')}") do |source|
source = source.split(":")
options.source = OpenStruct.new(githubs[source.first])
options.source.name = source.last
end
opts.on("-t", "--target [SITE:ACCOUNT]", "Organization or user name(s). Source only or source:destination.") do |source|
source = source.split(":")
options.dest = OpenStruct.new(githubs[source.first])
options.dest.name = source.last
end
opts.on("-p", "--tags", "Include tags when pushing") do |v|
options.push_tags = v
end
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
options[:verbose] = v
end
opts.on_tail("--version", "Show version") do
puts Salmon::VERSION
exit
end
end.parse!(args)
self.validate!(options)
options
end
|