Module: NexClient::Commands::Organizations

Extended by:
Helpers
Defined in:
lib/nex_client/commands/organizations.rb

Constant Summary collapse

ORGS_TITLE =
"Organizations".colorize(:green)
ORGS_HEADERS =
['id','name','handle'].map(&:upcase)

Constants included from Helpers

Helpers::LOG_COLORS

Class Method Summary collapse

Methods included from Helpers

display_logs, display_record_errors, error, success

Class Method Details

.display_organizations(list) ⇒ Object



23
24
25
26
27
28
29
30
31
# File 'lib/nex_client/commands/organizations.rb', line 23

def self.display_organizations(list)
  table = Terminal::Table.new title: ORGS_TITLE, headings: ORGS_HEADERS do |t|
    [list].flatten.compact.each do |e|
      t.add_row([e.id,e.name,e.handle])
    end
  end
  puts table
  puts "\n"
end

.list(args, opts) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/nex_client/commands/organizations.rb', line 10

def self.list(args,opts)
  # Display list
  list = NexClient::Organization.order('handle')
  self.display_organizations(list)

  # Loop through results
  while (list.pages.links||{})['next']
    ask("Press enter for next page")
    list = list.pages.next
    self.display_organizations(list)
  end
end