diff options
Diffstat (limited to 'bin/hostinfo')
-rwxr-xr-x | bin/hostinfo | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/bin/hostinfo b/bin/hostinfo index c5bb9c3..98c2162 100755 --- a/bin/hostinfo +++ b/bin/hostinfo @@ -90,8 +90,12 @@ def print_search(basepath, flags, search): data = _get_data(os.path.join(basepath, host)) key, result = match(data, search) if result is not None: + if flags.only_names: + print(_get_label(host)) + continue + if key is None: - print(host) + print(_get_label(host)) else: p = printer.Printer(data, flags) p.info(key, label=_get_label(host), maxlength=max(length)) @@ -192,6 +196,8 @@ def main(): help="lists all available hosts") parser.add_argument("-s", "--short", action="store_true", help="remove the domain from the output") + parser.add_argument("--only-names", action="store_true", + help="only print the hostname of the matching entries") args = parser.parse_args() if args.path: |