-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtrex
executable file
·43 lines (36 loc) · 1016 Bytes
/
trex
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
42
43
#!/usr/bin/env ruby
require 'optparse'
options = {}
opt_parser = OptionParser.new do |opt|
opt.banner = "Usage: trex COMMAND [OPTIONS]"
opt.separator ""
opt.separator "Commands"
opt.separator " name: "
opt.separator ""
opt.separator "Options"
opt.on("-n","--name NAME","tell the trex what to call you (ruby, go, nodejs)") do |name|
options[:name] = name
end
opt.on("-h","--help","help") do
puts opt_parser
end
end
opt_parser.parse!
name = options[:name] || 'ruby'
case ARGV[0]
when "ruby"
STDERR.puts "Using ruby programing language\n"
STDERR.puts "T-rex is running on http://localhost:5000\n"
STDERR.puts "Hit CTRL-C to stop the server"
system "ruby ruby_server.rb"
when "go"
STDERR.puts "Using Go programing language\n"
STDERR.puts "Hit CTRL-C to stop the server"
system "go run go_server.go"
when "nodejs"
STDERR.puts "Using nodejs\n"
STDERR.puts "T-rex is running on http://localhost:5000\n"
system "http-server -p 5000"
else
puts opt_parser
end