From 67177a327c7e3cb542561c6b3d5352faab190d7b Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Sun, 2 Jun 2013 22:37:07 +0200 Subject: hostinfo: add filter for matching hosts With the filter argument only the specified key is printed for all matching hosts. The filter argument for searches, does work like the filter argument for normal queries. --- bin/hostinfo | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/hostinfo b/bin/hostinfo index 0a65443..2270208 100755 --- a/bin/hostinfo +++ b/bin/hostinfo @@ -72,7 +72,7 @@ def match(host, search): return (None, True) return (search, result) -def print_search(basepath, flags, search): +def print_search(basepath, flags, search, filter_key=None): def _get_label(host): if flags.short: return host.replace('.spline.inf.fu-berlin.de','') @@ -95,8 +95,8 @@ def print_search(basepath, flags, search): continue p = printer.Printer(data, flags) - if flags.details: - p.info(None, label=_get_label(host), maxlength=max(length)) + if filter_key is not None flags.details: + p.info(filter_key, label=_get_label(host), maxlength=max(length)) else: if key is None: print(_get_label(host)) @@ -219,7 +219,7 @@ def main(): if args.name.startswith('?'): # search - print_search(basepath, search=args.name, flags=args) + print_search(basepath, search=args.name, filter_key=args.filter, flags=args) else: # info path = find_host(basepath, args.name) -- cgit v1.2.3-1-g7c22