Sha256: de95cfccc91c1763cf8b3765925c58f905bf5e1f1cec546a929e69265234118f
Contents?: true
Size: 1.15 KB
Versions: 4
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true require "core" require "refinements/structs" module Pragmater module CLI module Parsers # Parses common command line flags. class Flag using Refinements::Structs def self.call(...) = new(...).call def initialize configuration = Container[:configuration], client: Parser::CLIENT @configuration = configuration @client = client end def call arguments = ::Core::EMPTY_ARRAY client.separator "\nOPTIONS:\n" collate client.parse arguments configuration end private attr_reader :configuration, :client def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method } def add_comments client.on "--comments a,b,c", Array, "Add pragma comments. Default: []." do |comments| configuration.merge! comments: end end def add_includes client.on "--includes a,b,c", Array, "Add include patterns. Default: []." do |includes| configuration.merge! includes: end end end end end end
Version data entries
4 entries across 4 versions & 1 rubygems