Sha256: 17039a15138e9e41c18d33f5d9e736e5a8bacc9a8de9ec97a0d1401014884f11

Contents?: true

Size: 951 Bytes

Versions: 16

Compression:

Stored size: 951 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 command =~ /-*version/i
          puts "ORS v#{ORS::VERSION}"
        else
          if available_commands.include? klass
            ORS::Config.parse_options options
            ORS::Config.parse_config_file

            if ORS::Config.valid_options?
              Base.run ORS::Commands.const_get(klass)
            else
              info "ERROR: Invalid options given."
              Base.run Help
            end
          else
            Base.run Help
          end
        end
      end

      private

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

    end
    extend ClassMethods

  end

end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
ors-0.2.10 lib/ors/command.rb
ors-0.2.9 lib/ors/command.rb
ors-0.2.8 lib/ors/command.rb
ors-0.2.7 lib/ors/command.rb
ors-0.2.6 lib/ors/command.rb
ors-0.2.5 lib/ors/command.rb
ors-0.2.4 lib/ors/command.rb
ors-0.2.3 lib/ors/command.rb
ors-0.2.2 lib/ors/command.rb
ors-0.2.1 lib/ors/command.rb
ors-0.2.0 lib/ors/command.rb
ors-0.1.8 lib/ors/command.rb
ors-0.1.7 lib/ors/command.rb
ors-0.1.5 lib/ors/command.rb
ors-0.1.4 lib/ors/command.rb
ors-0.1.3 lib/ors/command.rb