class Rubysmith::CLI::Parsers::Build

Handles parsing of Command Line Interface (CLI) build options.

Public Class Methods

call(...) click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 8
  def self.call(...) = new(...).call

  def initialize options: {}, client: CLIENT
    @options = options
    @client = client
  end

  def call arguments = []
    client.separator "\nBUILD OPTIONS:\n"
    private_methods.sort.grep(/add_/).each { |method| __send__ method }
    arguments.empty? ? arguments : client.parse!(arguments)
  end

  private

  attr_reader :options, :client

  def add_minimum
    client.on "--min", "Use minimum/no options." do |value|
      options[:build_minimum] = value
    end
  end

  def add_amazing_print
    client.on "--[no-]amazing_print", "Add Amazing Print." do |value|
      options[:build_amazing_print] = value
    end
  end

  def add_bundler_leak
    client.on "--[no-]bundler-leak", "Add Bundler Leak." do |value|
      options[:build_bundler_leak] = value
    end
  end

  def add_console
    client.on "--[no-]console", "Add console script." do |value|
      options[:build_console] = value
    end
  end

  def add_documentation
    client.on "--[no-]documentation", "Add documentation." do |value|
      options[:build_documentation] = value
    end
  end

  def add_git
    client.on "--[no-]git", "Add Git." do |value|
      options[:build_git] = value
    end
  end

  def add_git_lint
    client.on "--[no-]git-lint", "Add Git Lint." do |value|
      options[:build_git_lint] = value
    end
  end

  def add_guard
    client.on "--[no-]guard", "Add Guard." do |value|
      options[:build_guard] = value
    end
  end

  def add_pry
    client.on "--[no-]pry", "Add Pry." do |value|
      options[:build_pry] = value
    end
  end

  def add_rake
    client.on "--[no-]rake", "Add Rake." do |value|
      options[:build_rake] = value
    end
  end

  def add_reek
    client.on "--[no-]reek", "Add Reek." do |value|
      options[:build_reek] = value
    end
  end

  def add_refinements
    client.on "--[no-]refinements", "Add Refinements." do |value|
      options[:build_refinements] = value
    end
  end

  def add_rspec
    client.on "--[no-]rspec", "Add RSpec." do |value|
      options[:build_rspec] = value
    end
  end

  def add_rubocop
    client.on "--[no-]rubocop", "Add Rubocop." do |value|
      options[:build_rubocop] = value
    end
  end

  def add_setup
    client.on "--[no-]setup", "Add setup script." do |value|
      options[:build_setup] = value
    end
  end

  def add_simple_cov
    client.on "--[no-]simple_cov", "Add SimpleCov." do |value|
      options[:build_simple_cov] = value
    end
  end

  def add_zeitwerk
    client.on "--[no-]zeitwerk", "Add Zeitwerk." do |value|
      options[:build_zeitwerk] = value
    end
  end
end
new(options: {}) click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 10
def initialize options: {}, client: CLIENT
  @options = options
  @client = client
end

Public Instance Methods

add_amazing_print() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 31
def add_amazing_print
  client.on "--[no-]amazing_print", "Add Amazing Print." do |value|
    options[:build_amazing_print] = value
  end
end
add_bundler_leak() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 37
def add_bundler_leak
  client.on "--[no-]bundler-leak", "Add Bundler Leak." do |value|
    options[:build_bundler_leak] = value
  end
end
add_console() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 43
def add_console
  client.on "--[no-]console", "Add console script." do |value|
    options[:build_console] = value
  end
end
add_documentation() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 49
def add_documentation
  client.on "--[no-]documentation", "Add documentation." do |value|
    options[:build_documentation] = value
  end
end
add_git() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 55
def add_git
  client.on "--[no-]git", "Add Git." do |value|
    options[:build_git] = value
  end
end
add_git_lint() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 61
def add_git_lint
  client.on "--[no-]git-lint", "Add Git Lint." do |value|
    options[:build_git_lint] = value
  end
end
add_guard() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 67
def add_guard
  client.on "--[no-]guard", "Add Guard." do |value|
    options[:build_guard] = value
  end
end
add_minimum() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 25
def add_minimum
  client.on "--min", "Use minimum/no options." do |value|
    options[:build_minimum] = value
  end
end
add_pry() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 73
def add_pry
  client.on "--[no-]pry", "Add Pry." do |value|
    options[:build_pry] = value
  end
end
add_rake() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 79
def add_rake
  client.on "--[no-]rake", "Add Rake." do |value|
    options[:build_rake] = value
  end
end
add_reek() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 85
def add_reek
  client.on "--[no-]reek", "Add Reek." do |value|
    options[:build_reek] = value
  end
end
add_refinements() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 91
def add_refinements
  client.on "--[no-]refinements", "Add Refinements." do |value|
    options[:build_refinements] = value
  end
end
add_rspec() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 97
def add_rspec
  client.on "--[no-]rspec", "Add RSpec." do |value|
    options[:build_rspec] = value
  end
end
add_rubocop() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 103
def add_rubocop
  client.on "--[no-]rubocop", "Add Rubocop." do |value|
    options[:build_rubocop] = value
  end
end
add_setup() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 109
def add_setup
  client.on "--[no-]setup", "Add setup script." do |value|
    options[:build_setup] = value
  end
end
add_simple_cov() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 115
def add_simple_cov
  client.on "--[no-]simple_cov", "Add SimpleCov." do |value|
    options[:build_simple_cov] = value
  end
end
add_zeitwerk() click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 121
def add_zeitwerk
  client.on "--[no-]zeitwerk", "Add Zeitwerk." do |value|
    options[:build_zeitwerk] = value
  end
end
call(arguments = []) click to toggle source
# File lib/rubysmith/cli/parsers/build.rb, line 15
def call arguments = []
  client.separator "\nBUILD OPTIONS:\n"
  private_methods.sort.grep(/add_/).each { |method| __send__ method }
  arguments.empty? ? arguments : client.parse!(arguments)
end