Sha256: fd3f6d377dd25eb324d2ae3eaecf1919ba2259e532c2e84fc9ce5c69b5fa275b

Contents?: true

Size: 1.65 KB

Versions: 1

Compression:

Stored size: 1.65 KB

Contents

#!/usr/bin/env ruby
=begin rdoc
=RubyNEAT Launcher based on thor

=end

require 'thor'
require 'semver'

# Be sure rnlib is added to the library path
%w{ lib neater neater/rnlib }.each do |dir|
  $:.unshift File.join([Dir.pwd, dir])
end

NEATER = File.join [Dir.pwd, "neater"]
NEATGLOB = NEATER + '/*_neat.rb'

require 'rubyneat'

module RubyNEAT
  module Cli

    class List < Thor
      desc 'neaters', 'List all Neaters.'
      def neaters
        Dir.glob(NEATGLOB).sort.each do |ne|
          puts 'neat runeater ' + File.basename(ne).gsub(%r{_neat\.rb}, '')
        end
      end

      desc 'neurons', 'List all Neurons.'
      def neurons
        puts NEAT::Neuron.neuron_types.map{|n| n.name }.sort.join "\n"
      end
    end

    class Main < Thor
      class_option :verbose, type: :string, banner: '[1|2|3]'

      desc 'list <type>', 'List the requested type.'
      subcommand 'list', List

      desc 'version', 'Display RubyNEAT version'
      def version
        puts SemVer.find.format "%M.%m.%p%s"
      end

      desc 'console', 'Run RubyNEAT interactively'
      def console
        #TODO: Finish the console
        puts "Not Implemented Yet."
      end

      desc 'runeater <neater> [<neater> <neater> ...] [OPTS]', 'Run a Neater'
      option :log, type: :string, banner: 'info|warn|debug|error'
      def runeater(*neaters)
        NEAT::controller.verbosity = options[:verbose].to_i if options[:verbose]
        eval %{$log.level = Logger::#{options[:log].upcase}} if options[:log]

        neaters.map do |neater|
          "#{neater}_neat.rb"
        end.each do |file|
          load file
        end
      end
    end
  end
end

RubyNEAT::Cli::Main.start(ARGV)

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubyneat-0.3.5.alpha.3 bin/neat