-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathopt_parser.rb
executable file
·41 lines (33 loc) · 936 Bytes
/
opt_parser.rb
1
2
3
4
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
#!/usr/bin/env ruby
require 'optparse'
options = {}
opt_parser = OptionParser.new do |opt|
opt.banner = "Usage: opt_parser COMMAND [OPTIONS]"
opt.separator ""
opt.separator "Commands"
opt.separator " start: start server"
opt.separator " stop: stop server"
opt.separator " restart: restart server"
opt.separator ""
opt.separator "Options"
opt.on("-e","--envrionment ENVRIONMENT","which enviroment you want server run") do |envrionment|
options[:envrionment] = envrionment
end
opt.on("-d","--daemon","runing on daemon mode?") do
options[:daemon] = true
end
opt.on("-h","--help","help") do
puts opt_parser
end
end
opt_parser.parse!
case ARGV[0]
when "start"
puts "call start on options #{options.inspect}"
when "stop"
puts "call stop on options #{options.inspect}"
when "restart"
puts "call restart on options #{options.inspect}"
else
puts opt_parser
end