Sha256: 472432b964b8d19182d067792c53f4d29cc9c8fa843d83c94958ee36919ea930

Contents?: true

Size: 742 Bytes

Versions: 1

Compression:

Stored size: 742 Bytes

Contents

require 'sshkit/interactive'
require 'color_echo'

def exception_handling
  begin
    yield
  rescue SSHKit::Command::Failed => e
    error e
    e.inspect.each_line do |line|
      return line.chomp! if line =~ /stderr/
    end
  end
end

def try_to_execute(cmd)
  exception_handling { execute cmd }
end

def try_to_capture(cmd)
  exception_handling { capture cmd }
end

def raise_error_with_usage(msg)
  STDERR.puts(msg)
  usage
  exit 1
end

def usage
  puts '(e.g. bundle exec cap staging operator:apply operation=sample)'
end

def warn_highlight
  CE.once.ch_fg(:red)
  yield
end

def enable_highlight(strings)
  strings.each do |string|
    CE.pickup(string, :h_red, nil, :bold)
  end
end

def disable_highlight
  CE.reset(:pickup)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
capistrano-operator-1.0.0 lib/capistrano/tasks/rake_helpers.rb