Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

make optparse

  • Loading branch information...
commit e73f25a31f0c81e092bb88aa87b3e1617574ec87 1 parent 1f1b8be
@hsbt hsbt authored
Showing with 2 additions and 61 deletions.
  1. +1 −61 bin/atig
  2. +1 −0  lib/atig.rb
View
62 bin/atig
@@ -10,66 +10,6 @@ self_file =
end
$:.unshift(File.dirname(self_file) + "/../lib")
-require "optparse"
-
-opts = {
- :port => 16668,
- :host => "localhost",
- :log => nil,
- :debug => false,
- :foreground => false,
- :conf => '~/.atig/config',
-}
-
-OptionParser.new do |parser|
- parser.instance_eval do
- self.banner = <<EOB.gsub(/^\t+/, "")
-age: #{$0} [opts]
-EOB
- separator ""
-
- separator "Options:"
- on("-p", "--port [PORT=#{opts[:port]}]", "port number to listen") do |port|
- opts[:port] = port
- end
-
- on("-h", "--host [HOST=#{opts[:host]}]", "host name or IP address to listen") do |host|
- opts[:host] = host
- end
-
- on("-l", "--log LOG", "log file") do |log|
- opts[:log] = log
- end
-
- on("--debug", "Enable debug mode") do |debug|
- opts[:log] ||= $stderr
- opts[:debug] = true
- end
-
- on("--memprof", "Enable memory profiler") do|_|
- require 'memory_profiler'
- require 'fileutils'
- FileUtils.mkdir_p "log"
- MemoryProfiler.start(:string_debug => true)
- end
-
- on("-c","--conf [file=#{opts[:conf]}]", "atig configuration file; default is '~/.atig/config'") do|name|
- opts[:conf] = name
- end
-
- parse!(ARGV)
- end
-end
-
-require 'logger'
-opts[:logger] = Logger.new(opts[:log], "weekly")
-opts[:logger].level = opts[:debug] ? Logger::DEBUG : Logger::INFO
-
-conf = File.expand_path opts[:conf]
-if File.exist? conf then
- opts[:logger].info "Loading #{conf}"
- load conf
-end
-
require 'atig'
+opts = Atig::OptParser.parse!(ARGV)
Net::IRC::Server.new(opts[:host], opts[:port], Atig::Gateway::Session, opts).start
View
1  lib/atig.rb
@@ -9,6 +9,7 @@
require 'atig/version'
require 'atig/monkey'
+require 'atig/optparse'
require 'atig/twitter'
require 'atig/scheduler'
require 'atig/agent'
Please sign in to comment.
Something went wrong with that request. Please try again.