2011-07-27 06:06:10 +02:00
|
|
|
require 'thor'
|
2011-12-21 20:03:45 +01:00
|
|
|
require "thor/group"
|
2011-07-27 06:06:10 +02:00
|
|
|
|
2011-12-21 20:03:45 +01:00
|
|
|
# CLI Module
|
2011-12-21 21:13:28 +01:00
|
|
|
module Middleman::Cli
|
2011-12-21 20:03:45 +01:00
|
|
|
|
|
|
|
class Base < Thor
|
2011-11-10 23:35:27 +01:00
|
|
|
desc "version", "Show version"
|
2011-08-03 23:43:02 +02:00
|
|
|
def version
|
|
|
|
require 'middleman/version'
|
|
|
|
say "Middleman #{Middleman::VERSION}"
|
|
|
|
end
|
|
|
|
|
2011-12-21 22:23:43 +01:00
|
|
|
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
|
|
|
|
|
2011-12-21 21:13:28 +01:00
|
|
|
def method_missing(meth, *args)
|
|
|
|
meth = meth.to_s
|
|
|
|
|
|
|
|
if self.class.map.has_key?(meth)
|
|
|
|
meth = self.class.map[meth]
|
|
|
|
end
|
|
|
|
|
|
|
|
klass, task = Thor::Util.find_class_and_task_by_namespace("#{meth}:#{meth}")
|
|
|
|
args.unshift(task) if task
|
|
|
|
klass.start(args, :shell => self.shell)
|
|
|
|
end
|
2011-07-27 06:06:10 +02:00
|
|
|
end
|
2011-12-14 08:58:34 +01:00
|
|
|
end
|
2011-12-21 20:03:45 +01:00
|
|
|
|
2011-12-21 21:13:28 +01:00
|
|
|
require "middleman/cli/init"
|
2011-12-21 20:03:45 +01:00
|
|
|
require "middleman/cli/server"
|
|
|
|
require "middleman/cli/build"
|