Sha256: b086ee6061930c900abb04446aa193dccf923d6248a97204910198fc92bba51f

Contents?: true

Size: 805 Bytes

Versions: 1

Compression:

Stored size: 805 Bytes

Contents

module VagrantShellCommander
  # Option parser
  #
  class OptionManager
    # Main parsing method
    # @return [Hash] The keys are :parser for the object returned by
    #   OptionParser and :values for the actual option values
    #
    def execute
      options = {}
      block = lambda do |parser|
        parser.banner = "Usage: vagrant sh -c 'COMMAND' -d [DIR] [MACHINE]"

        parser.separator ''

        parser.on('-d [DIR]', '--directory [DIR]', 
                  'Directory to execute the command') do |dir|
          options[:dir] = dir
        end

        parser.on("-c 'COMMAND'", "--command 'COMMAND'", 
                  'Command to execute') do |cmd|
          options[:cmd] = cmd
        end
      end

      {parser: OptionParser.new(&block), values: options}
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
vagrant-shell-commander-0.1.3 lib/vagrant-shell-commander/option_manager.rb