You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

32 lines
1.1 KiB

  1. from nilmdb.utils.printf import *
  2. import nilmdb.client
  3. from argparse import ArgumentDefaultsHelpFormatter as def_form
  4. def setup(self, sub):
  5. cmd = sub.add_parser("rename", help="Rename a stream",
  6. formatter_class = def_form,
  7. description="""
  8. Rename a stream.
  9. Only the stream's path is renamed; no
  10. metadata is changed.
  11. """)
  12. cmd.set_defaults(handler = cmd_rename)
  13. group = cmd.add_argument_group("Required arguments")
  14. group.add_argument("oldpath",
  15. help="Old path, e.g. /foo/old",
  16. ).completer = self.complete.path
  17. group.add_argument("newpath",
  18. help="New path, e.g. /foo/bar/new",
  19. ).completer = self.complete.path
  20. return cmd
  21. def cmd_rename(self):
  22. """Rename a stream"""
  23. try:
  24. self.client.stream_rename(self.args.oldpath, self.args.newpath)
  25. except nilmdb.client.ClientError as e:
  26. self.die("error renaming stream: %s", str(e))