Sha256: 5dc89a5c341dbdb255de27544a0fbe7a4ca4244a897adb5267476b91c0027997
Contents?: true
Size: 1.12 KB
Versions: 3
Compression:
Stored size: 1.12 KB
Contents
require 'optparse' require 'ostruct' module ActiveLdap module Command module_function def parse_options(argv=nil, version=nil) argv ||= ARGV.dup options = OpenStruct.new opts = OptionParser.new do |opts| yield(opts, options) opts.separator "" opts.separator "Common options:" opts.on_tail("--config=CONFIG", "Specify configuration file written as YAML") do |file| require 'yaml' config = YAML.load(File.read(file)).symbolize_keys Configuration::DEFAULT_CONFIG.update(config) end opts.on_tail("-h", "--help", "Show this message") do puts opts exit end opts.on_tail("--version", "Show version") do puts(version || VERSION) exit end end opts.parse!(argv) [argv, opts, options] end def read_password(prompt, input=$stdin, output=$stdout) output.print prompt system "/bin/stty -echo" if input.tty? input.gets.chomp ensure system "/bin/stty echo" if input.tty? output.puts end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
ruby-activeldap-0.8.1 | lib/active_ldap/command.rb |
ruby-activeldap-0.8.2 | lib/active_ldap/command.rb |
ruby-activeldap-0.8.0 | lib/active_ldap/command.rb |