Sha256: c72fd7f5a7b2c5699c97ea6577b78e134527ccd14a75b38e30eb630ef4f095cd

Contents?: true

Size: 1.41 KB

Versions: 11

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

require "refinements/structs"

module Pennyworth
  module CLI
    module Parsers
      # Handles parsing of Command Line Interface (CLI) GitHub options.
      class GitHub
        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.separator "\nGITHUB OPTIONS:\n"
          private_methods.sort.grep(/add_/).each { |method| __send__ method }
          client.parse arguments
          configuration
        end

        private

        attr_reader :configuration, :client

        def add_organization
          client.on(
            "--organization [HANDLE]",
            %(Set organization. Default: "#{organization}".)
          ) do |handle|
            configuration.merge! action_git_hub: :organization,
                                 git_hub_organization: handle || organization
          end
        end

        def add_user
          client.on "--user [HANDLE]", %(Set user. Default: "#{user}".) do |handle|
            configuration.merge! action_git_hub: :user, git_hub_user: handle || user
          end
        end

        def organization = configuration.git_hub_organization

        def user = configuration.git_hub_user
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
pennyworth-14.0.0 lib/pennyworth/cli/parsers/git_hub.rb
pennyworth-13.8.0 lib/pennyworth/cli/parsers/git_hub.rb
pennyworth-13.7.0 lib/pennyworth/cli/parsers/git_hub.rb
pennyworth-13.6.0 lib/pennyworth/cli/parsers/git_hub.rb
pennyworth-13.5.0 lib/pennyworth/cli/parsers/git_hub.rb
pennyworth-13.4.0 lib/pennyworth/cli/parsers/git_hub.rb
pennyworth-13.3.0 lib/pennyworth/cli/parsers/git_hub.rb
pennyworth-13.2.0 lib/pennyworth/cli/parsers/git_hub.rb
pennyworth-13.1.0 lib/pennyworth/cli/parsers/git_hub.rb
pennyworth-13.0.1 lib/pennyworth/cli/parsers/git_hub.rb
pennyworth-13.0.0 lib/pennyworth/cli/parsers/git_hub.rb