From 1d09cdf6342cfd715c366e881ced1d1f22d1503a Mon Sep 17 00:00:00 2001 From: Martin Kosek Date: Tue, 28 Feb 2012 15:04:05 +0100 Subject: Improve dnsrecord interactive help Add 2 new features to DNS record interactive help to increase its usability and also make its behavior more consistent with standard parameter interactive help: 1) Ask for missing DNS parts When a required part of a newly added DNS record was missing, we just returned a ValidationError. Now, the interactive help rather asks for all missing required parts of all DNS records that were being added by its parts. 2) Let user amend invalid part When an interactive help asked for a DNS record part value and user enters an invalid value, the entire interactive help exits with an error. This may upset a user if he already entered several correct DNS record part values. Now, the help rather tells user what's wrong and give him an opportunity to amend the value. https://fedorahosted.org/freeipa/ticket/2386 --- ipalib/cli.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'ipalib/cli.py') diff --git a/ipalib/cli.py b/ipalib/cli.py index e232c3ed..737ae001 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -529,6 +529,9 @@ class textui(backend.Backend): print raise PromptFailed(name=label) + def print_prompt_attribute_error(self, attribute, error): + self.print_plain('>>> %s: %s' % (attribute, error)) + def prompt(self, label, default=None, get_values=None, optional=False): """ Prompt user for input. @@ -1160,7 +1163,8 @@ class cli(backend.Executioner): error = None while True: if error is not None: - print '>>> %s: %s' % (unicode(param.label), unicode(error)) + self.Backend.textui.print_prompt_attribute_error(unicode(param.label), + unicode(error)) raw = self.Backend.textui.prompt(param.label, default, optional=param.alwaysask or not param.required) try: value = param(raw, **kw) -- cgit