Sha256: 4673fd8e3df6b351f50f266e616e12b707afd9a0363d2e6ef67e270d692ad464

Contents?: true

Size: 920 Bytes

Versions: 1

Compression:

Stored size: 920 Bytes

Contents

# frozen_string_literal: true

require "cli/command"
require "yaml"

module RailsInteractive
  class CLI
    # Commands class for the interactive CLI module
    class CommandHandler
      def initialize
        @commands = Command.new.all
      end

      def handle_multi_options(options, dependencies = nil)
        handle_dependencies(dependencies)
        options.each { |option| system("bin/rails app:template LOCATION=templates/setup_#{option}.rb") }
      end

      def handle_option(option, dependencies = nil)
        handle_dependencies(dependencies)
        system("bin/rails app:template LOCATION=templates/setup_#{option}.rb")
      end

      def handle_dependencies(dependencies)
        dependencies&.each do |dependency|
          puts ">> Dependency Detected: #{dependency} "
          system("bin/rails app:template LOCATION=templates/setup_#{dependency}.rb")
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails-interactive-2.1.0 lib/cli/command_handler.rb