Module: Pullr::CommandLine

Included in:
SCM::Git, SCM::Mercurial, SCM::Rsync, SCM::SubVersion
Defined in:
lib/pullr/command_line.rb

Instance Method Summary collapse

Instance Method Details

#cd(path) { ... } ⇒ Object

Changes directories.

Parameters:

  • path (String)

    Path to the new directory.

Yields:

  • [] If a block is given, then the directory will only be changed temporarily, then changed back after the block has finished.



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/pullr/command_line.rb', line 13

def cd(path,&block)
  if block
    pwd = Dir.pwd
    Dir.chdir(path)

    block.call()

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

#sh(program, *args) ⇒ Object

Runs a command.

Parameters:

  • program (String)

    The name or path of the program to run.

  • args (Array<String>)

    The additional arguments to run with the program.



35
36
37
# File 'lib/pullr/command_line.rb', line 35

def sh(program,*args)
  system(program,*args)
end