Sha256: 3ff14439c8b720ade75edd82dc97f91a0f04bbf68d69b73d3b6f9a6f5247c43b

Contents?: true

Size: 1.21 KB

Versions: 42

Compression:

Stored size: 1.21 KB

Contents

require 'optparse'
require 'ostruct'

module ActiveLdap
  module Command
    include GetTextSupport

    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
          config = Base.prepare_configuration(config)
          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

42 entries across 42 versions & 3 rubygems

Version Path
activeldap-7.2.1 lib/active_ldap/command.rb
activeldap-7.2.0 lib/active_ldap/command.rb
activeldap-7.0.0 lib/active_ldap/command.rb
activeldap-6.1.0 lib/active_ldap/command.rb
activeldap-6.0.4 lib/active_ldap/command.rb
activeldap-6.0.3 lib/active_ldap/command.rb
activeldap-6.0.2 lib/active_ldap/command.rb
activeldap-6.0.1 lib/active_ldap/command.rb
activeldap-6.0.0 lib/active_ldap/command.rb
activeldap-5.2.4 lib/active_ldap/command.rb
activeldap-5.2.3 lib/active_ldap/command.rb
activeldap-5.2.2 lib/active_ldap/command.rb
activeldap-5.2.1 lib/active_ldap/command.rb
activeldap-5.2.0 lib/active_ldap/command.rb
activeldap-5.1.1 lib/active_ldap/command.rb
activeldap-5.1.0 lib/active_ldap/command.rb
activeldap-3.2.3 lib/active_ldap/command.rb
powerhome-activeldap-3.2.3 lib/active_ldap/command.rb
activeldap-4.0.6 lib/active_ldap/command.rb
activeldap-4.0.5 lib/active_ldap/command.rb