Sha256: c6f61b2bdb18fec223d039df489e3a13688df6cd5a4fd1c64b6b68e96bc82a16
Contents?: true
Size: 1.02 KB
Versions: 2
Compression:
Stored size: 1.02 KB
Contents
# frozen_string_literal: true require 'io/console' require 'uffizzi' require 'uffizzi/auth_helper' module Uffizzi class CLI::Projects include ApiClient def run return unless Uffizzi::AuthHelper.signed_in? hostname = ConfigFile.read_option(:hostname) response = fetch_projects(hostname) if response[:code] == Net::HTTPOK handle_succeed_response(response) else handle_failed_response(response) end end private def handle_failed_response(response) ApiClient.print_errors(response[:body][:errors]) end def handle_succeed_response(response) projects = response[:body][:projects] if projects.empty? puts 'No projects related to this email' return end if projects.size == 1 ConfigFile.write_option(:project, projects.first[:slug]) end print_projects(projects) end def print_projects(projects) projects.each do |project| puts (project[:slug]).to_s end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
uffizzi-cli-0.1.2 | lib/uffizzi/cli/projects.rb |
uffizzi-cli-0.1.0 | lib/uffizzi/cli/projects.rb |