From b4285fb949e2f7206425b344b88b70a691e648eb Mon Sep 17 00:00:00 2001 From: Adrien Thebo Date: Thu, 22 Dec 2011 10:26:11 -0800 Subject: [PATCH] Implemented member listing for orgunits --- lib/gtool/provision/orgunit.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/gtool/provision/orgunit.rb b/lib/gtool/provision/orgunit.rb index d854478..8e10646 100644 --- a/lib/gtool/provision/orgunit.rb +++ b/lib/gtool/provision/orgunit.rb @@ -42,6 +42,25 @@ def get(orgunit_name) end end + desc "members ORGUNIT", "Get the members of an orgunit" + def members(orgunit_name) + connection = Gtool::Auth.connection(options) + orgunit = GData::Provision::OrgUnit.get(connection, orgunit_name) + fields = GData::Provision::OrgMember.attribute_names + field_names = GData::Provision::OrgMember.attribute_titles + + members = orgunit.list_members + + rows = members.map do |member| + fields.map {|f| member.send f} + end + + rows.unshift field_names + print_table rows + say "#{rows.length - 1} entries.", :cyan + end + + def self.banner(task, namespace = true, subcommand = false) "#{basename} #{task.formatted_usage(self, true, subcommand)}" end