-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtmud.rb
executable file
·90 lines (79 loc) · 2.59 KB
/
tmud.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
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
86
87
88
89
#!/usr/bin/env ruby
#
# file:: tmud.rb
# author:: Jon A. Lambert
# version:: 2.8.0
# date:: 01/19/2006
#
# This source code copyright (C) 2005, 2006 by Jon A. Lambert
# All rights reserved.
#
# Released under the terms of the TeensyMUD Public License
# See LICENSE file for additional information.
#
$:.unshift "lib" if !$:.include? "lib"
$:.unshift "vendor" if !$:.include? "vendor"
require 'optparse'
require 'utility/utility'
require 'utility/configuration'
require 'engine/engine'
require 'utility/version'
#
# Processes command line arguments
#
def get_options
# parse options
begin
# The myopts specified on the command line will be collected in *myopts*.
# We set default values here.
myopts = {}
opts = OptionParser.new do |opts|
opts.banner = BANNER
opts.separator ""
opts.separator "Usage: ruby #{$0} [options]"
opts.separator ""
opts.on("-p", "--port PORT", Integer,
"Select the port the mud will run on") {|port| myopts['server_port'] = port}
opts.on("-d", "--dbfile DBFILE", String,
"Select the name of the database file",
" (default is 'db/world.yaml')") {|db| myopts['dbfile'] = db}
opts.on("-c", "--config CONFIGFILE", String,
"Select the name of the configuration file",
" (default is 'config.yaml')") {|cfile| myopts['configfile'] = cfile}
opts.on("-l", "--logfile LOGFILE", String,
"Select the name of the log file",
" (default is 'logs/server.log')") {|lfile| myopts['logfile'] = lfile}
opts.on("-h", "--home LOCATIONID", Integer,
"Select the object id where new characters will start") {|home| myopts['home'] = home}
opts.on("-t", "--[no-]trace", "Trace execution") {|t| myopts['trace'] = t}
opts.on("-v", "--[no-]verbose", "Run verbosely") {|v| myopts['verbose'] = v}
opts.on_tail("-h", "--help", "Show this message") do
$stdout.puts opts.help
exit
end
opts.on_tail("--version", "Show version") do
$stdout.puts "TeensyMud #{Version}"
exit
end
end
opts.parse!(ARGV)
return myopts
rescue OptionParser::ParseError
$stderr.puts "ERROR - #{$!}"
$stderr.puts "For help..."
$stderr.puts " ruby #{$0} --help"
exit
end
end
###########################################################################
# This is start of the main driver.
###########################################################################
if $0 == __FILE__
begin
$cmdopts = get_options
$cmdopts.each do |key,val|
Configuration.instance.options[key] = val
end
Engine.instance.run
end
end