Sha256: a301b2b97f4b1c3cc5b01a9d9307927f2cf2d94c1d6ea76974dd49f87f0742ca
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
module Ing module Commands class Help DEFAULTS = { namespace: 'ing:commands', ing_file: 'ing.rb' } def self.specify_options(parser) parser.text "Display help on specified command" parser.text "\nUsage:" parser.text " ing help generate # help on built-in command 'generate'" parser.text " ing help unit --namespace test # help on command 'unit' within namespace 'test'" parser.text " ing help --namespace test:unit # another syntax" parser.text " ing help test:unit # yet another syntax" parser.text " ing help # display this message" end include Ing::CommonOptions attr_accessor :options attr_writer :shell def shell @shell ||= ::Ing.shell_class.new end def initialize(options) self.options = options end # Require each passed file or library before running # and require the ing file if it exists def before require_libs require_ing_file end def call(cmd=nil) before if options[:namespace_given] if cmd _do_help cmd, _namespace_class else _do_help _namespace_class end else if cmd if /:/ =~ cmd _do_help cmd else _do_help cmd, _namespace_class end else _do_help 'help', _namespace_class end end end private def _do_help(cmd, ns=::Object) klass = Util.decode_class(cmd, ns) help = Command.new(klass).help shell.say help end def _namespace_class(ns=options[:namespace]) Util.decode_class(ns) end end H = Help end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ing-0.2.7 | lib/ing/commands/help.rb |