Sha256: 58dcde84f0f56afc8bbedd8087e06ec9bdceba3132daeb80c15f1c10e3b5491f
Contents?: true
Size: 1.93 KB
Versions: 2
Compression:
Stored size: 1.93 KB
Contents
# frozen_string_literal: true require "refinements/structs" module Git module Lint 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 = Container[:configuration], client: Parser::CLIENT @configuration = configuration @client = client end def call arguments = [] client.banner = "#{Identity::LABEL} - #{Identity::SUMMARY}" client.separator "\nUSAGE:\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_analyze client.on "-a", "--analyze [options]", "Analyze current branch commits." do configuration.merge! action_analyze: true end end def add_config client.on( "-c", "--config ACTION", %i[edit view], "Manage gem configuration. Actions: edit or view." ) do |action| configuration.merge! action_config: action end end def add_hook client.on "--hook PATH", "Hook for analyzing unsaved commits." do |path| configuration.merge! action_hook: Pathname(path) 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 end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
git-lint-3.0.2 | lib/git/lint/cli/parsers/core.rb |
git-lint-3.0.1 | lib/git/lint/cli/parsers/core.rb |