Sha256: a0ad473a2e0a106bf3dcfe6191cf2572489340db2cb1d9d43683808be0a8de6f

Contents?: true

Size: 826 Bytes

Versions: 1

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' --cwd [DIR] [MACHINE]"

        parser.separator ''

        parser.on('--cwd [DIR]', '--change-working-dir [DIR]', 
                  'Directory to execute the command') do |cwd|
          options[:cwd] = cwd
        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

1 entries across 1 versions & 1 rubygems

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