Use better description for group names in help and always prompt for members

When running <foo>-[add|remove]-member completely interactively it didn't
prompt for managing membership, it just reported that 0 members were
handled which was rather confusing.

This will work via a shell if you want to echo too:

$ echo "" | ipa group-add-member g1

This returns 0 members because nothing is read for users or group members.

$ echo -e "g1\nadmin\n" | ipa group-add-member

This adds the user admin to the group g1. It adds it as a user because
user membership is prompted for first.

ticket 415
This commit is contained in:
Rob Crittenden 2010-12-02 16:19:00 -05:00
parent ac62447329
commit df592c6cc8

View File

@ -503,9 +503,11 @@ class textui(backend.Backend):
prompt = u'%s: ' % label
else:
prompt = u'%s [%s]: ' % (label, default)
return self.decode(
raw_input(self.encode(prompt))
)
try:
data = raw_input(self.encode(prompt))
except EOFError:
return None
return self.decode(data)
def prompt_password(self, label):
"""
@ -887,8 +889,9 @@ class cli(backend.Executioner):
``self.env.prompt_all`` is ``True``, this method will prompt for any
params that have a missing values, even if the param is optional.
"""
for param in cmd.params():
if (param.required and param.name not in kw) or self.env.prompt_all:
for param in cmd.params():
if (param.required and param.name not in kw) or \
param.alwaysask or self.env.prompt_all:
if param.password:
kw[param.name] = self.Backend.textui.prompt_password(
param.label