Sha256: ceb72965cbdd043fbd7dde66421ad9d4d6261aa997cbaecc6618ac60a1a86c6b

Contents?: true

Size: 774 Bytes

Versions: 3

Compression:

Stored size: 774 Bytes

Contents

module Pullr
  module CommandLine
    #
    # Changes directories.
    #
    # @param [String] path
    #   Path to the new directory.
    #
    # @yield []
    #   If a block is given, then the directory will only be changed
    #   temporarily, then changed back after the block has finished.
    #
    def cd(path,&block)
      if block
        pwd = Dir.pwd
        Dir.chdir(path)

        block.call()

        Dir.chdir(pwd)
      else
        Dir.chdir(path)
      end
    end

    #
    # Runs a command.
    #
    # @param [String] program
    #   The name or path of the program to run.
    #
    # @param [Array<String>] args
    #   The additional arguments to run with the program.
    #
    def sh(program,*args)
      system(program,*args)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pullr-0.1.3 lib/pullr/command_line.rb
pullr-0.1.2 lib/pullr/command_line.rb
pullr-0.1.1 lib/pullr/command_line.rb