[Freeipa-devel] [PATCH] 228 add function to prompt for entry after multiple results in -find
Rob Crittenden
rcritten at redhat.com
Tue Jun 9 17:45:01 UTC 2009
Rob Crittenden wrote:
> Jason Gerard DeRose wrote:
>> On Mon, 2009-06-08 at 17:41 -0400, Rob Crittenden wrote:
>>> The -find commands right now just dump all the data that was found.
>>> This function can be used to display a list of the results so the
>>> user can select a specfic record that will be displayed.
>>>
>>> I think that we'll ultimitely implement this within the LDAPObject
>>> class to make it easier on plugin developers. What they will need to
>>> provide is the format line that will be used and the attributes to
>>> display.
>>>
>>> The code looks something like:
>>>
>>> selected = textui.select_entry(users,
>>> "%(givenname)s %(sn)s
>>> (%(uid)s)",
>>> ("givenname", "sn", "uid"))
>>> if selected == -2:
>>> # Don't show anything else
>>> return
>>>
>>> if selected >= 0:
>>> users = [users[selected]]
>>> counter = 1
>>>
>>> for u in xrange(counter):
>>> cmd = api.Command['user_show']
>>> result = cmd(users[u]['uid'].decode('UTF-8'), **options)
>>> if callable(cmd.output_for_cli):
>>> for param in cmd.params():
>>> if param.password and param.name in options:
>>> del options[param.name]
>>> (args, options) = cmd.params_2_args_options(**options)
>>> cmd.output_for_cli(self.api.Backend.textui, result,
>>> *args, **options)
>>>
>>> This demonstrates the full code in output_for_cli() for the current
>>> user plugin. It looks like this to the user:
>>>
>>> % ipa user-find tim
>>> ---------------
>>> Found 3 matches
>>> ---------------
>>> 1: Tim User (tuser1)
>>> 2: Tim User (tuser2)
>>> 3: Tim User (tuser3)
>>> Choose one: (1 - 3), a for all, q to quit:
>>
>> I think this is a reasonable approach, although it would be nice to
>> allow the user just display the details on all the entries also. This
>> is important if you want to compare entries, like, "There are 10 Jason's
>> where I work, I'll search for 'Jason' and find the one I'm looking for
>> because I forgot the last name." Dumping all the results (the way we do
>> now) probably has important scripting use-cases too.
>
> Enter 'a' and all entries will be displayed. If there is no controlling
> API then all entries will be displayed as well. You can also pipe your
> choice in: echo "a" | ipa user-find jason
>
>> When you have less than 10 or so matches, IHMO the drill down approach
>> is slower and more cumbersome for the user... it would be faster to
>> scroll through the results to find the one you want. I personally feel
>> we should keep the way we currently do things the default and add an
>> option for this kind of drill down. Either way, there should be an
>> option to switch from one behavior to another.
>
> Ok, that should be doable. I still want to use the -show command to
> actually display any results to eliminate code duplication though. We'll
> have to see if it is worth the price of additional requests. It was
> pretty peppy on my system FWIW.
>
>> Another nitpick: the "Found 3 matches" should really be at the bottom of
>> the list as it's extremely useful in helping the user evaluate their
>> search, so we don't want it to scroll off the top when there are many
>> results.
>
> Ok, that's reasonable. I'll work on a fresh patch.
All I can do with the patch thus far is to re-arrange where we print the
search totals. The other work will be done once the new LDAP backend and
baseclasses are committed.
rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: freeipa-228-2-select.patch
Type: application/mbox
Size: 4781 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20090609/81efd433/attachment.mbox>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3245 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://listman.redhat.com/archives/freeipa-devel/attachments/20090609/81efd433/attachment.bin>
More information about the Freeipa-devel
mailing list