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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
# File 'lib/deploy/cli.rb', line 16
def invoke(args)
@options = OpenStruct.new
parser = OptionParser.new do |opts|
opts.banner = "Usage: deployhq [options] command"
opts.separator ""
opts.separator "Commands:"
opts.separator "deploy\t\t Start a new deployment"
opts.separator "servers\t\t List configured servers and server groups"
opts.separator "configure\t\t Create a new configuration file for this tool"
opts.separator ""
opts.separator "Common Options:"
@options.config_file = './Deployfile'
opts.on("-c", "--config path", 'Configuration file path') do |config_file_path|
@options.config_file = config_file_path
end
opts.on("-p", "--project project",
"Project to operate on (default is read from project: in config file)") do |project_permalink|
@options.project = project_permalink
end
opts.on_tail('-v', '--version', "Shows Version") do
puts Deploy::VERSION
exit
end
opts.on_tail("-h", "--help", "Displays Help") do
puts opts
exit
end
end
begin
parser.parse!(args)
command = args.pop
rescue OptionParser::InvalidOption
STDERR.puts parser.to_s
exit 1
end
unless command == 'configure'
begin
Deploy.configuration_file = @options.config_file
rescue Errno::ENOENT
STDERR.puts "Couldn't find configuration file at #{@options.config_file.inspect}"
exit 1
end
project_permalink = @options.project || Deploy.configuration.project
if project_permalink.nil?
STDERR.puts "Project must be specified in config file or as --project argument"
exit 1
end
@project = Deploy::Project.find(project_permalink)
end
case command
when 'deploy'
deploy
when 'servers'
server_list
when 'configure'
configure
else
STDERR.puts parser.to_s
end
end
|