Sha256: 8c8c61ada50ca9b414ca4abc743448ca41e41dcaa087596e235c108fb5887e8c

Contents?: true

Size: 830 Bytes

Versions: 4

Compression:

Stored size: 830 Bytes

Contents

module Ruboty
  class CommandBuilder
    include Mem

    attr_reader :arguments

    def initialize(arguments = ARGV)
      @arguments = arguments
    end

    def build
      command_class.new(options)
    end

    private

    def command_class
      case
      when options[:generate]
        Commands::Generate
      when options[:help]
        Commands::Help
      else
        Commands::Run
      end
    end

    def options
      Slop.parse(arguments) do |options|
        options.on("--dotenv", "Load .env before running.")
        options.on("-g", "--generate", "Generate a new chatterbot with ./ruboty/ directory if specified.")
        options.on("-h", "--help", "Display this help message.")
        options.string("-l", "--load", "Load a ruby file before running.")
      end
    end
    memoize :options
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ruboty-1.1.8 lib/ruboty/command_builder.rb
ruboty-1.1.7 lib/ruboty/command_builder.rb
ruboty-1.1.6 lib/ruboty/command_builder.rb
ruboty-1.1.5 lib/ruboty/command_builder.rb