12345678910111213141516171819202122232425262728293031323334353637383940 |
- #!/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("link_name")
- argparser.add_argument("--relative", action = "store_true")
- argparser.add_argument("--override", action = "store_true")
- argparser.add_argument("--no-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["backup"] = not params["no_backup"]
- del params["no_backup"]
- try:
- osex.symlink(**params)
- except Exception, ex:
- print(ex)
- return 1
- return 0
- if __name__ == "__main__":
- sys.exit(main(sys.argv[1:]))
|