module Crabfarm::Support::GLI

Public Class Methods

generate_options(_cmd) click to toggle source
# File lib/crabfarm/support/gli.rb, line 4
def self.generate_options(_cmd)
  Configuration::OPTIONS.each do |opt|
    if opt.type != :mixed
      _cmd.desc opt.text
      _cmd.flag "cf-#{opt.name}"
    end
  end
end
parse_options(_options) click to toggle source
# File lib/crabfarm/support/gli.rb, line 22
def self.parse_options(_options)
  config_overrides = {}
  Configuration::OPTIONS.each do |opt|
    value = _options["cf-#{opt.name}"]
    next if value.nil?

    value = if opt.type.is_a? Array
      opt.type.find { |t| t.to_s == value }
    elsif opt.type == :integer then value.to_i
    elsif opt.type == :float then value.to_f
    elsif opt.type == :boolean then [true, false].find { |t| t.to_s == value }
    elsif opt.type == :string then value
    else nil end
    next if value.nil?

    config_overrides[opt.name] = value
  end
  config_overrides
end
require_all() click to toggle source
# File lib/crabfarm/support/gli.rb, line 18
def self.require_all
  Dir.glob(File.join(CF_PATH, 'app', '**/*.rb')).each { |p| require p }
end
setup_autoload() click to toggle source
# File lib/crabfarm/support/gli.rb, line 13
def self.setup_autoload
  require 'active_support/dependencies'
  ActiveSupport::Dependencies.autoload_paths += Dir.glob File.join(CF_PATH, 'app', '**')
end