diff --git a/.travis.yml b/.travis.yml index 42d69998..0a20771c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,5 +2,4 @@ rvm: - 1.8.7 - 1.9.2 - 1.9.3 - - jruby script: "bundle exec rake test" \ No newline at end of file diff --git a/lib/middleman/cli.rb b/lib/middleman/cli.rb index db83b002..f5160ace 100644 --- a/lib/middleman/cli.rb +++ b/lib/middleman/cli.rb @@ -5,23 +5,29 @@ require "thor/group" module Middleman::Cli class Base < Thor - include Thor::Actions - - class_option "help", - :type => :boolean, - :default => false, - :aliases => "-h" - def initialize(*) - super - help_check if options[:help] - end - desc "version", "Show version" def version require 'middleman/version' say "Middleman #{Middleman::VERSION}" end + def help(meth = nil, subcommand = false) + if meth && !self.respond_to?(meth) + klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}") + klass.start(["-h", task].compact, :shell => self.shell) + else + list = [] + Thor::Util.thor_classes_in(Middleman::Cli).each do |klass| + list += klass.printable_tasks(false) + end + list.sort!{ |a,b| a[0] <=> b[0] } + + shell.say "Tasks:" + shell.print_table(list, :ident => 2, :truncate => true) + shell.say + end + end + def method_missing(meth, *args) meth = meth.to_s @@ -29,18 +35,10 @@ module Middleman::Cli meth = self.class.map[meth] end - # initialize_thorfiles(meth) klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}") args.unshift(task) if task klass.start(args, :shell => self.shell) end - - private - - def help_check - help self.class.send(:retrieve_task_name, ARGV.dup) - exit 0 - end end end