Sha256: 2a2ef487001c70b04a91afdfcd810697d32d64c37c520cb20633570565d0417c

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module RailsAppGenerator
  module Cli
    # Folder Diff
    class Profile < Thor
      desc 'xxx [options]', 'Create a new rails app based on a RAG profile'

      option :profile_path            , type: :string
      option :fallback_profile_path   , type: :string

      # rubocop:disable Metrics/AbcSize
      def profile(name)
        path          = options[:profile_path] || options[:fallback_profile_path]
        profile_name  = name.end_with?('.json') ? name : "#{name}.json"
        profile_file  = File.join(path, profile_name)

        unless File.exist?(profile_file)
          puts "Profile [#{profile_file}] not found"
          exit 1
        end

        puts "Using profile #{profile_file}"

        profile       = JSON.parse(File.read(profile_file), symbolize_names: true)
        args          = profile[:args]
        opts          = RailsAppGenerator::RailsOptions.new(profile[:opts])

        RailsAppGenerator::Util.write_last_run('rails_options_data.json', opts.to_h)

        starter = RailsAppGenerator::Starter.new(**args)
        starter.start(opts) if starter.handle_target_folder_existence?
      end
      # rubocop:enable Metrics/AbcSize
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rails_app_generator-0.3.0 lib/rails_app_generator/cli/profile.rb