#!/usr/bin/env ruby require "rubygems" require "thor" require "railsthemes" class Installer < Thor desc "default", "The default task to run when no command is given" method_option :version, :desc => "See what version you have installed", :aliases => ['-v', '--version'], :type => :boolean def default if options[:version] puts Railsthemes::VERSION else puts <<-EOS Usage: railsthemes -v # Print the version of the installer gem you are using railsthemes install your@email:code # Install from RailsThemes.com using your download code railsthemes list # List all themes installed in this app railsthemes use # Switch to use a different installed theme railsthemes help [TASK] # Describe available tasks or one specific task EOS end end default_task :default desc "install your@email:code", "Install from RailsThemes.com using your download code" method_option :file, :desc => "Install using local relative pathname instead of a code.", :type => :boolean method_option :staging, :desc => "Hit the staging server instead of https://railsthemes.com.", :type => :boolean method_option :server, :desc => "Hit an arbitrary server instead of https://railsthemes.com.", :type => :string method_option :no_doc_popup, :desc => "Do not pop up documentation on successful install.", :type => :boolean method_option :verbose, :desc => "Print more output on installation.", :type => :boolean # do not rename to :debug, conflicts with Thor built-in functionality method_option :debugging, :desc => "Print gratuitous output on installation (for debugging).", :type => :boolean def install code_or_file installer = Railsthemes::Installer.new options if options[:file] file = code_or_file abort 'Please specify a file to install from' unless file installer.install_from_file_system file else code = code_or_file abort 'Please specify a code to install from' unless code installer.install_from_code code end end desc "list", "List all themes installed in this app" def list switcher = Railsthemes::Switcher.new switcher.list end desc "use", "Use a RailsTheme Theme installed in this app" def use theme switcher = Railsthemes::Switcher.new switcher.switch_to theme end end Installer.start ARGV