Sha256: 4ad51e147b4a0029e86619ce6edae939469bf80714e1efc3a4e93bac8e38e130
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
# frozen_string_literal: true require "refinements/structs" module Tocer module CLI module Parsers # Handles parsing of Command Line Interface (CLI) core options. class Core using Refinements::Structs def self.call(...) = new(...).call def initialize configuration = Configuration::Loader.call, client: Parser::CLIENT, container: Container @configuration = configuration @client = client @container = container end def call arguments = [] client.banner = "Tocer - #{specification.summary}" client.separator "\nUSAGE:\n" collate client.parse arguments configuration end private attr_reader :configuration, :client, :container def collate = private_methods.sort.grep(/add_/).each { |method| __send__ method } def add_config client.on( "-c", "--config ACTION", %i[edit view], "Manage gem configuration: edit or view." ) do |action| configuration.merge! action_config: action end end def add_insert root_dir = configuration.root_dir client.on( "-i", "--insert [PATH]", %(Insert/update table of contents. Default: "#{root_dir}".) ) do |path| configuration.merge! action_insert: true, root_dir: path || root_dir end end def add_version client.on "-v", "--version", "Show gem version." do configuration.merge! action_version: true end end def add_help client.on "-h", "--help", "Show this message." do configuration.merge! action_help: true end end def specification = container[__method__] end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
tocer-13.1.0 | lib/tocer/cli/parsers/core.rb |