Sha256: bce263f78aa81e7fa2b53e1aba390a6f0060c59be5d0ae860c43536f21eff1d3

Contents?: true

Size: 1.85 KB

Versions: 2

Compression:

Stored size: 1.85 KB

Contents

module PactBroker
  module Client
    module CLI
      module PacticipantCommands
        PACTICIPANT_PARAM_NAMES = [:name, :display_name, :repository_url]

        def self.included(thor)
          thor.class_eval do
            desc 'create-or-update-pacticipant', 'Create or update pacticipant by name'
            method_option :name, type: :string, required: true, desc: "Pacticipant name"
            method_option :display_name, type: :string, desc: "Display name"
            method_option :repository_url, type: :string, required: false, desc: "The repository URL of the pacticipant"
            output_option_json_or_text
            shared_authentication_options
            verbose_option

            def create_or_update_pacticipant(*required_but_ignored)
              raise ::Thor::RequiredArgumentMissingError, "Pacticipant name cannot be blank" if options.name.strip.size == 0
              execute_pacticipant_command(params_from_options(PACTICIPANT_PARAM_NAMES), 'Create')
            end

            desc 'list-pacticipants', 'List pacticipants'
            output_option_json_or_text
            shared_authentication_options
            verbose_option
            def list_pacticipants
              execute_pacticipant_command(params_from_options(PACTICIPANT_PARAM_NAMES), 'List')
            end

            no_commands do
              def execute_pacticipant_command(params, command_class_name)
                require 'pact_broker/client/pacticipants'
                command_options = { verbose: options.verbose, output: options.output }
                result = PactBroker::Client::Pacticipants2.const_get(command_class_name).call(params, command_options, pact_broker_client_options)
                $stdout.puts result.message
                exit(1) unless result.success
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pact_broker-client-1.43.0 lib/pact_broker/client/cli/pacticipant_commands.rb
pact_broker-client-1.42.0 lib/pact_broker/client/cli/pacticipant_commands.rb