lib/cli/commands/admin.rb in vmc-0.3.10 vs lib/cli/commands/admin.rb in vmc-0.3.12.beta.1
- old
+ new
@@ -1,9 +1,28 @@
module VMC::Cli::Command
class Admin < Base
+ 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
+
+ alias :users :list_users
+
def add_user(email=nil)
email = @options[:email] unless email
password = @options[:password]
email = ask("Email: ") unless no_prompt || email
unless no_prompt || password
@@ -46,9 +65,10 @@
cmd = Services.new(@options)
services.each { |s| cmd.delete_service(s[:name])}
end
display 'Deleting User: ', false
+ client.proxy = nil
client.delete_user(user_email)
display 'OK'.green
end
end