Class: Fp::Commands::Projects
Overview
fp projects - list projects/workspaces the API key has access to
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Fp::Commands::Base
Instance Method Details
#run(_args) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/fp/commands/projects.rb', line 7 def run(_args) result = client.list_projects unless result[:ok] output.error(result[:error], status: result[:status]) exit 1 end workspaces = result[:data]['workspaces'] || [] output.success(result[:data]) do if workspaces.empty? puts 'No projects found.' else headers = %w[SLUG NAME SURFACES] rows = workspaces.map do |w| surfaces = (w['available_surfaces'] || []).join(', ') [w['slug'], w['name'], surfaces.empty? ? '-' : surfaces] end output.table(headers, rows) end end end |