Sha256: b5cc7f809197ba7ddced8aeb855ebbcf28e76b9d13aed55b5e9ed8c46b06982f

Contents?: true

Size: 826 Bytes

Versions: 2

Compression:

Stored size: 826 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 --cmd 'COMMAND' --dir [DIR] [MACHINE]"

        parser.separator ''

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

        parser.on("--cmd '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

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-shell-commander-0.1.2 lib/vagrant-shell-commander/option_manager.rb
vagrant-shell-commander-0.1.1 lib/vagrant-shell-commander/option_manager.rb