Class: Botbckt::Cmd
- Inherits:
-
Object
- Object
- Botbckt::Cmd
- Defined in:
- lib/botbckt/cmd.rb
Overview
:nodoc:
Constant Summary collapse
- SEVERITY =
%w{0 1 2 3 4 5}
- SEVERITY_ALIASES =
{ "DEBUG" => 0, "INFO" => 1, "WARN" => 2, "ERROR" => 3, "FATAL" => 4, "UNKNOWN" => 5}
Class Method Summary collapse
Class Method Details
.parse(args) ⇒ Object
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 |
# File 'lib/botbckt/cmd.rb', line 12 def self.parse(args) = {} [:user] = 'botbckt' [:port] = 6667 [:channels] = [] [:backend_port] = 6379 opts = OptionParser.new do |opts| opts. = 'Usage: botbckt [options]' opts.separator '' opts.separator 'Options:' opts.on('-u', '--user [USER]', 'Username to identify as. (default: botbckt)') do |user| [:user] = user end opts.on('-p', '--password [PASSWORD]', 'Password to authenticate with.') do |pass| [:password] = pass end opts.on('-s', '--server SERVER', 'Address of the IRC server.') do |server| [:server] = server end opts.on('-P', '--port [PORT]', Integer, 'Port of the IRC server. (default: 6667)') do |port| [:port] = port end opts.on('-c', '--channels [x,y,z]', Array, 'Comma-separated list of channels to JOIN. Do not include the # prefix.') do |channels| [:channels] = channels end opts.on('-l', '--logfile [FILE]', 'Log file. (default botbckt.log)') do |log| [:log] = log end severities = SEVERITY_ALIASES.keys.join(', ') opts.on('-V', '--verbosity [LEVEL]', SEVERITY, SEVERITY_ALIASES, Integer, "Minimum severity level to log.Accepted values are: #{severities}. (default: INFO)") do |level| [:log_level] = level end opts.on('-b', '--backend-host [SERVER]', 'Address of a Redis server.') do |backend| [:backend_host] = backend end opts.on('-B', '--backend-port [PORT]', Integer, 'Port of a Redis server. (default: 6379)') do |port| [:backend_port] = port end opts.on('-D', '--[no-]daemonize', 'Fork and run in the background. (default: true)') do |daemon| [:daemonize] = daemon end opts.on('-i', '--pid FILE', 'File to store PID (default: botbckt.pid)') do |file| [:pid] = file end opts.on_tail('-h', '--help', 'Show this message.') do |help| puts opts exit end end opts.parse!(args) rescue OptionParser::ParseError puts opts exit end |