From df592c6cc8314b2fe520761206fd4e651d4e43c8 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Thu, 2 Dec 2010 16:19:00 -0500 Subject: Use better description for group names in help and always prompt for members When running -[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 --- ipalib/cli.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'ipalib') diff --git a/ipalib/cli.py b/ipalib/cli.py index 3120e011..1be39256 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -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 -- cgit