# helpers

Optional

In case you need to define ruby methods in your runfile (for example, methods that provide services to multiple actions), use the helpers block directive.

title  'API Tools'

action 'download' do
  verify_api_key
  say "Downloading"
end

action 'upload' do
  verify_api_key
  say "Uploading"
end

helpers do
  def verify_api_key
    abort 'Please set API_KEY' unless ENV['API_KEY']
  end
end
$ run
Usage:
  run download
  run upload
  run (--help | -h)

$ run download
Please set API_KEY

$ API_KEY=123 run download
Downloading