Sha256: a89ed51faa457959b7f18e20d4b7a60e68984aa064a285121440e2554a3af51a

Contents?: true

Size: 1.26 KB

Versions: 2

Compression:

Stored size: 1.26 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 --namespace test unit  # help on command within namespace"
        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="help")
        before
        ns        = Ing::Util.to_class_names(options[:namespace] || 'object')
        cs        = Ing::Util.to_class_names(cmd)
        help = Dispatcher.new(ns, cs).help
        shell.say help.read
      end
      
    end
    
    H = Help
  
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ing-0.1.5 lib/ing/commands/help.rb
ing-0.1.2 lib/ing/commands/help.rb