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.
 
 
 

33 lines
1.1 KiB

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