lib/conjur/command/roles.rb in conjur-cli-2.1.9 vs lib/conjur/command/roles.rb in conjur-cli-2.2.1

- old
+ new

@@ -11,10 +11,11 @@ c.action do |global_options,options,args| id = require_arg(args, 'role') role = api.role(id) role.create(options) + puts "Created #{role}" end end desc "Determines whether a role exists" arg_name "role" @@ -28,28 +29,22 @@ desc "Lists role memberships" arg_name "role" command :memberships do |c| c.action do |global_options,options,args| - role = args.shift || api.user(api.username).roleid - display api.role(role).all.map(&:roleid) + roleid = args.shift + role = roleid.nil? && api.current_role || api.role(roleid) + display role.all.map(&:roleid) end end - desc "Lists members of the role" + desc "Lists all members of the role" arg_name "role" command :members do |c| - c.desc "List all members recursively" - c.switch :a - c.action do |global_options,options,args| role = args.shift || api.user(api.username).roleid - if options[:a] - display api.role(role).all.map(&:roleid) - else - display api.role(role).members.map(&:member).map(&:roleid) - end + display api.role(role).members.map(&:member).map(&:roleid) end end desc "Grant a role to another role. You must have admin permission on the granting role." arg_name "role member" @@ -60,10 +55,11 @@ c.action do |global_options,options,args| id = require_arg(args, 'role') member = require_arg(args, 'member') role = api.role(id) role.grant_to member, options[:admin] + puts "Role granted" end end desc "Revoke a role from another role." arg_name "role member" @@ -71,8 +67,9 @@ c.action do |global_options,options,args| id = require_arg(args, 'role') member = require_arg(args, 'member') role = api.role(id) role.revoke_from member + puts "Role revoked" end end end