123456789101112131415161718192021222324252627282930313233343536373839 |
- #!/usr/bin/python
- # PYTHON_ARGCOMPLETE_OK
- import osex
- import sys
- import argparse
- import argcomplete
- def _init_argparser():
- argparser = argparse.ArgumentParser(description = None)
- argparser.add_argument("source")
- argparser.add_argument("destination")
- argparser.add_argument("--no-override", action = "store_true")
- argparser.add_argument("--backup", action = "store_true")
- argparser.add_argument("--backup-suffix", default = "~")
- return argparser
- def main(argv):
- argparser = _init_argparser()
- argcomplete.autocomplete(argparser)
- args = argparser.parse_args(argv)
- params = vars(args)
- params["override"] = not params["no_override"]
- del params["no_override"]
- try:
- osex.renames(**params)
- except Exception, ex:
- print(ex)
- return 1
- return 0
- if __name__ == "__main__":
- sys.exit(main(sys.argv[1:]))
|