Sha256: dbb413a03522d100cdd4c2854a2ba4e0450bdd02c30e981c63172e53f1f002eb

Contents?: true

Size: 958 Bytes

Versions: 11

Compression:

Stored size: 958 Bytes

Contents

class User < CloudstackCli::Base

  desc 'list', 'list users'
  option :listall, type: :boolean, default: true
  option :account
  option :format, default: "table",
    enum: %w(table json yaml)
  def list
    resolve_account
    users = client.list_users(options)
    if users.size < 1
      say "No users found."
    else
      case options[:format].to_sym
      when :yaml
        puts({users: users}.to_yaml)
      when :json
        puts JSON.pretty_generate(users: users)
      else
        table = [%w(Account Type Name Username Email State Domain)]
        users.each do |user|
          table << [
            user['account'],
            Account::TYPES[user['accounttype']],
            "#{user['firstname']} #{user['lastname']}",
            user['username'], user['email'],
            user['state'], user['domain']
          ]
        end
        print_table table
        say "Total number of users: #{users.size}"
      end
    end
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
cloudstack-cli-1.6.10 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.6.9 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.6.8 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.6.7 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.6.6 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.6.5 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.6.4 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.6.3 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.6.2 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.6.1 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.6.0 lib/cloudstack-cli/commands/user.rb