# frozen_string_literal: true require 'optparse' require_relative '../lib/crys' require_relative 'mixins/splash' Options = Struct.new(:filepath) @options = Options.new OptionParser.new do |opts| opts.banner = 'Usage: builder.rb [options]' opts.on('-fPATH', '--file=PATH', 'File path') do |n| @options[:filepath] = n end opts.on('-a', '--all', 'Process all files') do |_v| @options[:filepath] = :all end end.parse! module Crys class BuilderRunner def initialize(file_path:, image_dir:, output_dir:, builder_class:, batch_builder_class:, theme_dir:, pages_db:) @file_path = file_path @output_dir = output_dir @builder_class = builder_class @batch_builder_class = batch_builder_class @image_dir = image_dir @theme_dir = theme_dir @pages_db = pages_db end def run if file_path == :all batch_builder_class.new(pages_db: pages_db, output_dir: output_dir, image_dir: image_dir, builder_class: builder_class).build else builder_class.new(file_path: file_path, output_dir: output_dir, image_dir: image_dir).build end end private attr_reader :builder_class, :file_path, :output_dir, :image_dir, :batch_builder_class, :theme_dir, :pages_db end end