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
55
|
# File 'lib/ccsh/options.rb', line 6
def self.parse_options(args)
options = OpenStruct.new
user_home = File.expand_path('~')
options.config = "#{user_home}/.ccsh/config.yaml"
options.hosts = "#{user_home}/.ccsh/hosts.yaml"
options.output = ""
options.debug = false
options.verbose = false
options.check = false
opt_parser = OptionParser.new do |opts|
opts.banner = "Usage: ccsh [options] GROUP1 GROUP2 ... "
opts.separator ""
opts.separator "Options: "
opts.on("-c", "--config CONFIG_FILE", "Configuration file (default: ~/.ccsh/config.yaml)") do |cfg|
options.config = cfg
end
opts.on("-d", "--[no-]debug", "Run Debug mode") do |d|
options.debug = d
end
opts.on("-h", "--hosts HOST_FILE", "Specified hosts file") do |h|
options.hosts = h
end
opts.on("-k", "--[no-]check", "Check host connection before continuing") do |k|
options.check = k
end
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
options.verbose = v
end
opts.on("--version", "Display version") do |v|
build = "build #{CCSH::BUILD_NUMBER}" if CCSH::BUILD_NUMBER != nil
puts "CCSH version #{CCSH::VERSION} #{build}"
exit
end
end
opt_parser.parse!(args)
options.targets = args
return options
end
|