fix cli docs

This commit is contained in:
Thomas Reynolds 2011-12-21 13:23:43 -08:00
parent 98b2b293c1
commit 79ded54e9c
2 changed files with 17 additions and 20 deletions

View file

@ -2,5 +2,4 @@ rvm:
- 1.8.7
- 1.9.2
- 1.9.3
- jruby
script: "bundle exec rake test"

View file

@ -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