Sha256: 04540dc3b8fbed16df533b1bf87373c445e15b97407359aa134166b95e303d97

Contents?: true

Size: 740 Bytes

Versions: 9

Compression:

Stored size: 740 Bytes

Contents

require "ors/commands/base"
Dir[File.join File.dirname(__FILE__), "commands", "*.rb"].each { |c| require c }

module ORS

  class Command

    module ClassMethods

      include ORS::Commands

      def run args
        command, *options = args
        klass = command.to_s.capitalize

        if available_commands.include? klass
          ORS::Config.parse_options options

          if ORS::Config.valid_options?
            Base.run ORS::Commands.const_get(klass)
          else
            Base.run Help
          end
        else
          Base.run Help
        end
      end

      private

      def available_commands
        ORS::Commands.constants.map {|klass| klass.to_s }
      end

    end
    extend ClassMethods

  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ors-0.0.9 lib/ors/command.rb
ors-0.0.8 lib/ors/command.rb
ors-0.0.7 lib/ors/command.rb
ors-0.0.6 lib/ors/command.rb
ors-0.0.5 lib/ors/command.rb
ors-0.0.4 lib/ors/command.rb
ors-0.0.3 lib/ors/command.rb
ors-0.0.2 lib/ors/command.rb
ors-0.0.1 lib/ors/command.rb