summaryrefslogtreecommitdiff
path: root/new/bin/builder.rb
blob: b5f5270b7b256a7290d438a4e3bf38016d38f26a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 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(batch_builder:, builder:, batch:)
      @builder = builder
      @batch_builder = batch_builder
      @batch = batch
    end

    def run
      p batch
      if batch
        batch_builder.build
      else
        builder.build
      end
    end

    private

    attr_reader :builder, :batch_builder, :batch
  end
end