module Enzyme

Public Instance Methods

error(error) click to toggle source
# File lib/enzyme.rb, line 72
def error(error)
  if $trace_errors && error.is_a?(StandardError)
    raise error
  else
    puts 'ERROR'
    puts '-----'
    puts ''
    puts '> '+error
    puts ''
  end
end
help() click to toggle source
# File lib/enzyme.rb, line 36
def help
  ARGV.reject { |x| x.start_with?("-") }
  command = ARGV.shift

  info

  if command
    if @@commands.include?(command.to_s.downcase)
      @@commands[command.to_s.downcase][:help].call
    else
      error("No help available for `#{name}`.")
    end
  else
    puts 'USAGE'
    puts '-----'
    puts ''
    puts '### Commands'
    puts ''
    puts '    enzyme config [<key> [<value> [--global]]]'
    puts '    enzyme create <project_name> [pms | koi]'
    # puts '    enzyme join <project_name>'
    puts '    enzyme sync [<project_name>]'
    puts ''
    puts '### Help'
    puts ''
    puts '    enzyme help [<command>]'
    puts '    enzyme [<command>] --help'
    puts '    enzyme [<command>] -h'
    puts ''
    puts '### Debugging'
    puts ''
    puts 'Use `--trace` at anytime to get full stacktraces.'
    puts ''
  end
end
info() click to toggle source
# File lib/enzyme.rb, line 26
def info
  puts 'ENZYME'
  puts '======'
  puts ''
  puts 'Katalyst\'s project collaboration tool.'
  puts ''
  puts 'Version: '+$version
  puts ''
end
register(command_class, &block) click to toggle source
# File lib/enzyme.rb, line 84
def register(command_class, &block)
  @@commands[command_class.to_s.downcase] = { :class => command_class, :help => block }
end
run() click to toggle source
# File lib/enzyme.rb, line 5
def run
  # Only shift the first argument off the ARGV if help flags haven't been passed.
  command = (ARGV.delete("-h") || ARGV.delete("--help")) ? 'help' : (ARGV.shift || 'help')

  # Show info, help or run the requested command if it has been registered.
  begin
    if command.eql?('help')
      help
    else
      if @@commands.include?(command.to_s.downcase)
        @@commands[command.to_s.downcase][:class].run()
      else
        error("Unable to find command `#{command}`.")
        help
      end
    end
  rescue StandardError => e
    error(e)
  end
end