Sha256: f203d9422ffa309c478a858eb92b0e7134c0d94ebb087a569358a4022767da0a
Contents?: true
Size: 1.45 KB
Versions: 5
Compression:
Stored size: 1.45 KB
Contents
# frozen_string_literal: true require "refinements/structs" module Gemsmith module CLI module Parsers # Handles parsing of Command Line Interface (CLI) build options. class Build using Refinements::Structs def self.call(...) = new(...).call def initialize configuration = Container[:configuration], client: Parser::CLIENT, container: Container @configuration = configuration @client = client @container = container end def call arguments = [] add_cli client.parse arguments configuration end private attr_reader :configuration, :client, :container def add_cli client.on( "--[no-]cli", "Add command line interface. #{default __method__}." ) do |value| configuration.merge! build_refinements: value, build_zeitwerk: value if value configuration.merge! build_cli: value end end def default option option.to_s .sub("add_", "build_") .then { |attribute| configuration.public_send attribute } .then { |boolean| boolean ? colorizer.green(boolean) : colorizer.red(boolean) } .then { |colored_boolean| "Default: #{colored_boolean}" } end def colorizer = container[__method__] end end end end
Version data entries
5 entries across 5 versions & 1 rubygems