fix cli docs
This commit is contained in:
parent
98b2b293c1
commit
79ded54e9c
2 changed files with 17 additions and 20 deletions
|
@ -2,5 +2,4 @@ rvm:
|
||||||
- 1.8.7
|
- 1.8.7
|
||||||
- 1.9.2
|
- 1.9.2
|
||||||
- 1.9.3
|
- 1.9.3
|
||||||
- jruby
|
|
||||||
script: "bundle exec rake test"
|
script: "bundle exec rake test"
|
|
@ -5,23 +5,29 @@ require "thor/group"
|
||||||
module Middleman::Cli
|
module Middleman::Cli
|
||||||
|
|
||||||
class Base < Thor
|
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"
|
desc "version", "Show version"
|
||||||
def version
|
def version
|
||||||
require 'middleman/version'
|
require 'middleman/version'
|
||||||
say "Middleman #{Middleman::VERSION}"
|
say "Middleman #{Middleman::VERSION}"
|
||||||
end
|
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)
|
def method_missing(meth, *args)
|
||||||
meth = meth.to_s
|
meth = meth.to_s
|
||||||
|
|
||||||
|
@ -29,18 +35,10 @@ module Middleman::Cli
|
||||||
meth = self.class.map[meth]
|
meth = self.class.map[meth]
|
||||||
end
|
end
|
||||||
|
|
||||||
# initialize_thorfiles(meth)
|
|
||||||
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
|
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
|
||||||
args.unshift(task) if task
|
args.unshift(task) if task
|
||||||
klass.start(args, :shell => self.shell)
|
klass.start(args, :shell => self.shell)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def help_check
|
|
||||||
help self.class.send(:retrieve_task_name, ARGV.dup)
|
|
||||||
exit 0
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue