module Crew::CLI::Processor

Public Instance Methods

dispatch(args) click to toggle source
# File lib/crew/cli.rb, line 6
def dispatch(args)
  if commands.include?(args.first)
    method(args.shift.gsub(/-/, '_').to_sym).call(args)
  elsif args.first.nil?
    help(args)
  else
    help(args)
    error "Unknown command #{args.join(", ")}"
  end
end

Private Instance Methods

crew_home() click to toggle source
# File lib/crew/cli.rb, line 29
def crew_home
  if path = find_crew_dir
    Home.new(path)
  else
    warn "No .crew/config file found"
    exit(1)
  end
end
find_crew_dir() click to toggle source
# File lib/crew/cli.rb, line 18
def find_crew_dir
  search_path = Dir.pwd
  while true
    break if File.exist?(File.join(search_path, ".crew"))
    new_path = File.expand_path("..", search_path)
    break if search_path == new_path
    search_path = new_path
  end
  search_path ? File.join(search_path, ".crew") : nil
end