module Markify::OptParser
Public Class Methods
parse!()
click to toggle source
# File lib/markify/optparser.rb, line 25 def self.parse! parse end
Protected Class Methods
parse()
click to toggle source
# File lib/markify/optparser.rb, line 31 def self.parse options = {} oparser = OptionParser.new do |opts| opts.banner = "Usage: #{$0} [options]" opts.separator "" opts.separator "Optional options:" opts.on('-s', '--send', 'Send XMPP messages') do |s| options[:send] = s end opts.on('-n', '--noop', 'No operation, only stdout output') do |n| options[:noop] = n end opts.on("-v", "--[no-]verbose", "Run verbosely") do |v| options[:verbose] = v end opts.separator "" opts.on("-f", "--config-file FILE", "Config file (default: ~/markify/config.yml)") do |file| options[:config_file] = Pathname(file) end opts.separator '' opts.separator 'Common options:' opts.on_tail('--init', 'Create example configuration') do if options[:config_file] Markify::Settings.create_exmple_config(options[:config_file]) else Markify::Settings.create_example_config end end opts.on_tail('--test', 'Test configuration and accounts') do options[:test] = true end opts.on_tail('-h', '--help', 'Show this message') do puts opts exit end opts.on_tail('--version', 'Show version information') do puts Markify::LICENCE exit end if ARGV.size == 0 puts Markify::DESCRIPTION puts puts opts puts puts Markify::LICENCE exit end end.parse! options end