Class: Scribbler::CLIClient

Inherits:
Object
  • Object
show all
Defined in:
lib/scribbler/cli_client.rb

Instance Method Summary collapse

Instance Method Details

#mass_copy(files, destination) ⇒ Object

Copy a list of files to one location with one output for the whole copy

files - List of strings representing files to be copied destination - Directory to send the files

Examples:

CLI.mass_copy(['/etc/a.file', 'etc/b.file'], '/tmp')
# "Copying files"
# => Nothing

Returns Nothing



42
43
44
45
46
47
# File 'lib/scribbler/cli_client.rb', line 42

def mass_copy(files, destination)
  output 'cp'
  files.each do |file|
    run_command "cp #{file} #{destination}", :output => false
  end
end

#run_command(command, poptions = {}) ⇒ Object

Run a shell command and output clean text explaining what happened

command - Shell command to run poptions - Set of options to alter default behavior

:output - Disable default out of the command (default: true)

Examples:

CLI.run_command('pwd')
# No output, because no pwd association yet
# => '/some/dir'

CLI.run_command('cp x y')
# Copying files
# => nothing

CLI.run_command('cp x y', :output => false)
# => nothing

Returns the backtick return of the command



23
24
25
26
27
# File 'lib/scribbler/cli_client.rb', line 23

def run_command(command, poptions={})
  options = {:output => true}.merge(poptions)
  output command if options[:output]
  `#{command}`
end