# HG changeset patch # User Goffi # Date 1605189196 -3600 # Node ID 7b4ae3dbc0411eaf40ad3d0a7fc27d6a2a59a5f3 # Parent f30b238d9c45fb3071e09c4a3a87ed5e121af366 jp (base, pubsub/set): new `--quiet` argument: `--quiet` can be used to only return essential data from command. This is notably useful to remove message and trailing line feed when returning a data which must be parsed by an other program. diff -r f30b238d9c45 -r 7b4ae3dbc041 sat_frontends/jp/base.py --- a/sat_frontends/jp/base.py Thu Nov 12 14:53:16 2020 +0100 +++ b/sat_frontends/jp/base.py Thu Nov 12 14:53:16 2020 +0100 @@ -316,6 +316,11 @@ '--verbose', '-v', action='count', default=0, help=_("Add a verbosity level (can be used multiple times)")) + quiet_parent = self.parents['quiet'] = argparse.ArgumentParser(add_help=False) + quiet_parent.add_argument( + '--quiet', '-q', action='store_true', + help=_("be quiet (only output machine readable data)")) + draft_parent = self.parents['draft'] = argparse.ArgumentParser(add_help=False) draft_group = draft_parent.add_argument_group(_('draft handling')) draft_group.add_argument( diff -r f30b238d9c45 -r 7b4ae3dbc041 sat_frontends/jp/cmd_pubsub.py --- a/sat_frontends/jp/cmd_pubsub.py Thu Nov 12 14:53:16 2020 +0100 +++ b/sat_frontends/jp/cmd_pubsub.py Thu Nov 12 14:53:16 2020 +0100 @@ -734,6 +734,7 @@ host, "set", use_pubsub=True, + use_quiet=True, pubsub_flags={C.NODE}, help=_("publish a new item or update an existing one"), ) @@ -770,7 +771,10 @@ self.host.quit(C.EXIT_BRIDGE_ERRBACK) else: if published_id: - self.disp("Item published at {pub_id}".format(pub_id=published_id)) + if self.args.quiet: + self.disp(published_id, end='') + else: + self.disp(f"Item published at {published_id}") else: self.disp("Item published") self.host.quit(C.EXIT_OK)