Mercurial > libervia-backend
comparison sat_frontends/jp/cmd_pubsub.py @ 3412:7b4ae3dbc041
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.
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 12 Nov 2020 14:53:16 +0100 |
parents | f30b238d9c45 |
children | f4d417593e77 |
comparison
equal
deleted
inserted
replaced
3411:f30b238d9c45 | 3412:7b4ae3dbc041 |
---|---|
732 base.CommandBase.__init__( | 732 base.CommandBase.__init__( |
733 self, | 733 self, |
734 host, | 734 host, |
735 "set", | 735 "set", |
736 use_pubsub=True, | 736 use_pubsub=True, |
737 use_quiet=True, | |
737 pubsub_flags={C.NODE}, | 738 pubsub_flags={C.NODE}, |
738 help=_("publish a new item or update an existing one"), | 739 help=_("publish a new item or update an existing one"), |
739 ) | 740 ) |
740 | 741 |
741 def add_parser_options(self): | 742 def add_parser_options(self): |
768 except Exception as e: | 769 except Exception as e: |
769 self.disp(_(f"can't send item: {e}"), error=True) | 770 self.disp(_(f"can't send item: {e}"), error=True) |
770 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 771 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
771 else: | 772 else: |
772 if published_id: | 773 if published_id: |
773 self.disp("Item published at {pub_id}".format(pub_id=published_id)) | 774 if self.args.quiet: |
775 self.disp(published_id, end='') | |
776 else: | |
777 self.disp(f"Item published at {published_id}") | |
774 else: | 778 else: |
775 self.disp("Item published") | 779 self.disp("Item published") |
776 self.host.quit(C.EXIT_OK) | 780 self.host.quit(C.EXIT_OK) |
777 | 781 |
778 | 782 |