Class: Twibot::CliConfig
Overview
Configuration from command line
Constant Summary
Constants inherited from Config
Instance Attribute Summary
Attributes inherited from Config
Instance Method Summary collapse
-
#initialize(args = $*) ⇒ CliConfig
constructor
A new instance of CliConfig.
Methods inherited from Config
#add, default, #method_missing, #to_hash
Constructor Details
#initialize(args = $*) ⇒ CliConfig
Returns a new instance of CliConfig.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/twibot/config.rb', line 87 def initialize(args = $*) super() @parser = OptionParser.new do |opts| opts. += "Usage: #{File.basename(Twibot.app_file)} [options]" opts.on("-m", "--min-interval SECS", Integer, "Minimum poll interval in seconds") { |i| @settings[:min_interval] = i } opts.on("-x", "--max-interval SECS", Integer, "Maximum poll interval in seconds") { |i| @settings[:max_interval] = i } opts.on("-s", "--interval-step SECS", Integer, "Poll interval step in seconds") { |i| @settings[:interval_step] = i } opts.on("-f", "--log-file FILE", "Log file") { |f| @settings[:log_file] = f } opts.on("-l", "--log-level LEVEL", "Log level (err, warn, info, debug), default id info") { |l| @settings[:log_level] = l } opts.on("-u", "--login LOGIN", "Twitter login") { |l| @settings[:login] = l } opts.on("-p", "--password PASSWORD", "Twitter password") { |p| @settings[:password] = p } opts.on("-h", "--help", "Show this message") { puts opts; exit } begin require 'daemons' opts.on("-d", "--daemonize", "Run as background process (Not implemented)") { |t| @settings[:daemonize] = true } rescue LoadError end end.parse!(args) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Twibot::Config