Method: VMC::Cli::Command::Admin#list_users

Defined in:
lib/cli/commands/admin.rb

#list_usersObject Also known as: users



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/cli/commands/admin.rb', line 5

def list_users
  users = client.users
  users.sort! {|a, b| a[:email] <=> b[:email] }
  return display JSON.pretty_generate(users || []) if @options[:json]

  display "\n"
  return display "No Users" if users.nil? || users.empty?

  users_table = table do |t|
    t.headings = 'Email', 'Admin', 'Apps'
    users.each do |user|
      t << [user[:email], user[:admin], user[:apps].map {|x| x[:name]}.join(', ')]
    end
  end
  display users_table
end