diff options
author | Alexander Sulfrian <alexander@sulfrian.net> | 2013-06-05 19:26:23 +0200 |
---|---|---|
committer | Alexander Sulfrian <alexander@sulfrian.net> | 2013-06-05 19:26:23 +0200 |
commit | ad32229c673b9ff01249590d0e042f1f1ba346ed (patch) | |
tree | f9291de9991c9b1ccde15d13e15c4addac0dc027 | |
parent | 1b850e286810a17668ccfa4aedbab6d6077608f8 (diff) | |
download | tools-ad32229c673b9ff01249590d0e042f1f1ba346ed.tar.gz tools-ad32229c673b9ff01249590d0e042f1f1ba346ed.tar.bz2 tools-ad32229c673b9ff01249590d0e042f1f1ba346ed.zip |
hostinfo: add --details option
With --details the whole hostinfo entry is displayed for all matching
hosts.
-rwxr-xr-x | bin/hostinfo | 13 | ||||
-rw-r--r-- | contrib/bash-completion | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/bin/hostinfo b/bin/hostinfo index 98c2162..0a65443 100755 --- a/bin/hostinfo +++ b/bin/hostinfo @@ -94,11 +94,14 @@ def print_search(basepath, flags, search): print(_get_label(host)) continue - if key is None: - print(_get_label(host)) + p = printer.Printer(data, flags) + if flags.details: + p.info(None, label=_get_label(host), maxlength=max(length)) else: - p = printer.Printer(data, flags) - p.info(key, label=_get_label(host), maxlength=max(length)) + if key is None: + print(_get_label(host)) + else: + p.info(key, label=_get_label(host), maxlength=max(length)) def print_info(path, flags, key=None): data = _get_data(path) @@ -198,6 +201,8 @@ def main(): help="remove the domain from the output") parser.add_argument("--only-names", action="store_true", help="only print the hostname of the matching entries") + parser.add_argument("-d", "--details", action="store_true", + help="print details about matching hosts") args = parser.parse_args() if args.path: diff --git a/contrib/bash-completion b/contrib/bash-completion index 333bf0e..4d64f08 100644 --- a/contrib/bash-completion +++ b/contrib/bash-completion @@ -49,7 +49,7 @@ _hostinfo() { COMPREPLY=( $( compgen -W "-o --oneline -f --file -k --keys -h -? --help -p --path -n --nospaces -l --hosts -s --short - -v --verbose --only-names + -v --verbose --only-names -d --details $_completion" -- $cur ) ) fi } |