From 9e070a14d49fea8e5d9dd5576d778b418c5d4598 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 15 Aug 2023 15:58:10 +0200 Subject: [PATCH] nodelist delimiters --- confluent_client/bin/nodelist | 13 ++++++++++--- confluent_client/doc/man/nodelist.ronn | 5 +++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/confluent_client/bin/nodelist b/confluent_client/bin/nodelist index b6892e53..c5815bc5 100755 --- a/confluent_client/bin/nodelist +++ b/confluent_client/bin/nodelist @@ -1,4 +1,4 @@ -#!/usr/bin/python2 +#!/usr/libexec/platform-python # vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright 2015-2017 Lenovo @@ -15,13 +15,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -__author__ = 'jjohnson2,alin37' +__author__ = 'jjohnson2,alin37,wgrzeda' import optparse import os import signal import sys + + try: signal.signal(signal.SIGPIPE, signal.SIG_DFL) except AttributeError: @@ -39,9 +41,12 @@ def main(): " or: %prog [options] noderange ...") argparser.add_option('-b', '--blame', action='store_true', help='Show information about how attributes inherited') + argparser.add_option('-d', '--delim', metavar="STRING", default = "\n", + help='Delimiter separating the values') (options, args) = argparser.parse_args() noderange="" nodelist="" + list = [] try: noderange = args[0] nodelist = '/noderange/{0}/nodes/'.format(noderange) @@ -61,7 +66,9 @@ def main(): sys.stderr.write(res['error'] + '\n') exitcode = 1 else: - print(res['item']['href'].replace('/', '')) + elem=(res['item']['href'].replace('/', '')) + list.append(elem) + print(*list, sep = options.delim) sys.exit(exitcode) diff --git a/confluent_client/doc/man/nodelist.ronn b/confluent_client/doc/man/nodelist.ronn index d2fc5ff5..bfe5a86b 100644 --- a/confluent_client/doc/man/nodelist.ronn +++ b/confluent_client/doc/man/nodelist.ronn @@ -4,7 +4,7 @@ nodelist(8) -- List confluent nodes and their attributes ## SYNOPSIS `nodelist ` -`nodelist [-b] ...` +`nodelist [-b] [-d] {string} ...` ## DESCRIPTION @@ -24,7 +24,8 @@ all attributes that begin with `net.` and end with `switch`. * `-b`, `--blame`: Annotate inherited and expression based attributes to show their base value. - +* `-d`, `--delim`: + Choose a delimiter to separat the values. Default - ENTER. ## EXAMPLES * Listing matching nodes of a simple noderange: `# nodelist n1-n4`