#!/usr/bin/env ruby require 'fileutils' if ARGV.size != 1 $stderr.puts 'Usage: joybox []' $stderr.puts 'Commands:' $stderr.puts ' install '.ljust(15) + 'Installs the Joybox RubyMotion Templates and Commands' $stderr.puts ' uninstall '.ljust(15) + 'Uninstall the Joybox RubyMotion Templates and Commands' exit 1 end if ARGV[0] == 'install' ruby_motion_directory = File.expand_path('~/Library/RubyMotion') template_directory = File.join(ruby_motion_directory, 'template') command_directory = File.join(ruby_motion_directory, 'command') FileUtils.mkdir_p(template_directory) unless File.directory?(template_directory) FileUtils.mkdir_p(command_directory) unless File.directory?(command_directory) joybox_template_directory = File.expand_path('../../template/', __FILE__) FileUtils.cp_r(Dir.glob("#{joybox_template_directory}/*"), template_directory) joybox_command_directory = File.expand_path('../../command', __FILE__) FileUtils.cp_r(Dir.glob("#{joybox_command_directory}/*"), command_directory) $stderr.puts 'Joybox RubyMotion Templates and Commands installed correctly' end if ARGV[0] == 'uninstall' ruby_motion_directory = File.expand_path('~/Library/RubyMotion') template_directory = File.join(ruby_motion_directory, 'template') command_directory = File.join(ruby_motion_directory, 'command') joybox_template_directory = File.expand_path('../../template', __FILE__) Dir.glob("#{joybox_template_directory}/**").each do |directory| directory = File.expand_path(File.basename(directory), template_directory) FileUtils.rm_r(directory) if File.exists?(directory) end Dir.glob("#{joybox_command_directory}/*").each do |directory| directory = File.expand_path(File.basename(directory), command_directory) FileUtils.rm_r(directory) if File.exists?(directory) end $stderr.puts 'Joybox RubyMotion Templates and Commands uninstalled correctly' end