module Runfile::DSL

Public Instance Methods

action(name = nil, shortcut = nil, &block) click to toggle source

Commands

# File lib/runfile/concerns/dsl.rb, line 5
def action(name = nil, shortcut = nil, &block)
  current_action.block = block
  current_action.name = name.to_s
  current_action.shortcut = shortcut.to_s if shortcut
  current_action.host = self
  finalize_current_action name.to_s
end
actions() click to toggle source

Evaluation Artifacts

# File lib/runfile/concerns/dsl.rb, line 87
def actions
  @actions ||= {}
end
env_var(name, help) click to toggle source
# File lib/runfile/concerns/dsl.rb, line 13
def env_var(name, help)
  env_vars[name] = help
end
env_vars() click to toggle source
# File lib/runfile/concerns/dsl.rb, line 95
def env_vars
  @env_vars ||= {}
end
example(text) click to toggle source
# File lib/runfile/concerns/dsl.rb, line 17
def example(text)
  examples.push text
end
examples() click to toggle source
# File lib/runfile/concerns/dsl.rb, line 99
def examples
  @examples ||= []
end
help(message) click to toggle source
# File lib/runfile/concerns/dsl.rb, line 21
def help(message)
  current_action.help = message
end
helper_blocks() click to toggle source
# File lib/runfile/concerns/dsl.rb, line 103
def helper_blocks
  @helper_blocks ||= []
end
helpers(&block) click to toggle source
# File lib/runfile/concerns/dsl.rb, line 25
def helpers(&block)
  helper_blocks.push block if block
  helper_blocks
end
import(pathspec, context = nil) click to toggle source
# File lib/runfile/concerns/dsl.rb, line 30
def import(pathspec, context = nil)
  imports[pathspec] = context
end
import_gem(pathspec, context = nil) click to toggle source
# File lib/runfile/concerns/dsl.rb, line 34
def import_gem(pathspec, context = nil)
  gem_name, glob = pathspec.split('/', 2)
  glob ||= '*'
  path = GemFinder.find gem_name, glob
  imports[path] = context
end
imports() click to toggle source
# File lib/runfile/concerns/dsl.rb, line 107
def imports
  @imports ||= {}
end
option(name, help) click to toggle source
# File lib/runfile/concerns/dsl.rb, line 41
def option(name, help)
  options[name] = help
end
options() click to toggle source
# File lib/runfile/concerns/dsl.rb, line 111
def options
  @options ||= {}
end
param(name, help) click to toggle source
# File lib/runfile/concerns/dsl.rb, line 45
def param(name, help)
  params[name] = help
end
params() click to toggle source
# File lib/runfile/concerns/dsl.rb, line 91
def params
  @params ||= {}
end
require_context(varname, default: nil) click to toggle source
# File lib/runfile/concerns/dsl.rb, line 49
def require_context(varname, default: nil)
  required_contexts[varname] = default
end
required_contexts() click to toggle source
# File lib/runfile/concerns/dsl.rb, line 53
def required_contexts
  @required_contexts ||= {}
end
shortcut(from, to) click to toggle source
# File lib/runfile/concerns/dsl.rb, line 57
def shortcut(from, to)
  shortcuts[from] = to
end
shortcuts() click to toggle source
# File lib/runfile/concerns/dsl.rb, line 115
def shortcuts
  @shortcuts ||= {}
end
summary(text = nil) click to toggle source
# File lib/runfile/concerns/dsl.rb, line 61
def summary(text = nil)
  return @summary unless text

  @summary = text
end
title(text = nil) click to toggle source
# File lib/runfile/concerns/dsl.rb, line 67
def title(text = nil)
  return @title unless text

  @title = text
end
usage(message) click to toggle source
# File lib/runfile/concerns/dsl.rb, line 73
def usage(message)
  message = "#{name} #{message}" if name
  message = "#{host.full_name} #{message}".strip if host
  current_action.usages.push message
end
version(text = nil) click to toggle source
# File lib/runfile/concerns/dsl.rb, line 79
def version(text = nil)
  return @version unless text

  @version = text
end

Private Instance Methods

current_action() click to toggle source
# File lib/runfile/concerns/dsl.rb, line 127
def current_action
  @current_action ||= Action.new
end
finalize_current_action(name) click to toggle source
# File lib/runfile/concerns/dsl.rb, line 121
def finalize_current_action(name)
  key = name.empty? ? :default : name
  actions[key] = current_action
  @current_action = nil
end