module NexusAPI::CLIUtils

Public Instance Methods

if_file_exists?(file: options[:filename], repository: options[:repository]) { || ... } click to toggle source
# File lib/nexus_api/cli_utils.rb, line 55
def if_file_exists?(file: options[:filename], repository: options[:repository])
  begin
    puts "Sending '#{file}' to the '#{repository}' repository in Nexus!"
    yield
  rescue Errno::ENOENT
    puts "'#{file}' does not exist locally."
  end
end
print_element(action:, params:, filter:) click to toggle source
print_paginating_set(action:, params:, filter:, proc: nil) click to toggle source
print_set(action:, filter:) click to toggle source
repository_set?() click to toggle source
# File lib/nexus_api/cli_utils.rb, line 42
def repository_set?
  if options[:repository].nil? && options[:team_config].nil?
    puts "No value provided for required option '--repository' or '--team_config' (only need 1)"
    return false
  end
  true
end
set(repository:) click to toggle source
# File lib/nexus_api/cli_utils.rb, line 50
def set(repository:)
  setup
  options[:repository] = @api.team_config.send(repository) if options[:repository].nil?
end
setup() click to toggle source
# File lib/nexus_api/cli_utils.rb, line 5
def setup
  Dotenv.load(options[:nexus_config])
  @api = NexusAPI::API.new(
    username: ENV['NEXUS_USERNAME'],
    password: ENV['NEXUS_PASSWORD'],
    hostname: ENV['NEXUS_HOSTNAME'],
    docker_pull_hostname: ENV['DOCKER_PULL_HOSTNAME'],
    docker_push_hostname: ENV['DOCKER_PUSH_HOSTNAME'],
    team_config: options[:team_config]
  )
end