Sha256: e1c9f777c5b09a194babaed7b0f52ffc9cec92f008fe289b866cc874541e568a
Contents?: true
Size: 1.68 KB
Versions: 2
Compression:
Stored size: 1.68 KB
Contents
require 'roxie' require 'thor' require 'thor/group' # Include the core CLI items Dir[File.expand_path('../cli/*.rb', __FILE__)].each { |f| require f } module Roxie module CLI class Base < Thor map ['-v', '--version'] => :version, 'd' => :doc class << self alias :old_register :register def register(klass, subcommand_name, usage, description, options={}) # Keep track of 'subgroups' as well as subcommands self.subgroups << subcommand_name.to_s if klass <= Thor::Group old_register(klass, subcommand_name, usage, description, options) end def subgroups @subgroups ||= from_superclass(:subgroups, []) end alias :old_task_help :task_help def task_help(shell, command_name) meth = normalize_task_name(command_name) if subgroups.include?(meth) # Make sure to namespace all subcommands appropriately klass = Thor::Util.find_by_namespace(meth) klass.help(shell) else old_task_help(shell, command_name) end end alias :command_help :task_help end default_task :doc desc "version", "Prints Roxie's version information" def version say "Roxie #{Roxie::VERSION}" klass, task = Thor::Util.find_class_and_command_by_namespace("doc:doc") end def method_missing(meth, *args) # Assume the user typed in a file input for the # :doc command Doc.start(args.unshift(meth.to_s), :shell => self.shell) end end # Subcommands Base.register Doc, 'doc', "doc [INPUT]", "Generates documentation from input files" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
roxie-0.0.3 | lib/roxie/cli.rb |
roxie-0.0.2 | lib/roxie/cli.rb |