diff --git a/README.md b/README.md index c1d98e8..4f2dd51 100644 --- a/README.md +++ b/README.md @@ -3,5 +3,6 @@ Options: -h, --help show this help message and exit -i, --install installs t3make00 (~/.bashrc) + -u, --uninstall uninstalls t3make00 (~/.bashrc) -p PROJECT, --project=PROJECT name of the project (defaults to value args[0]) \ No newline at end of file diff --git a/t3make00 b/t3make00 index 4564408..260814d 100755 --- a/t3make00 +++ b/t3make00 @@ -128,7 +128,7 @@ def install(): teensy_tools_tar.extractall(path=base_tools) teensy_tools_tar.close() - print "#3 updating PATH" + print "#3 updating ~/.bashrc" home = os.path.expanduser("~") bashrc = os.path.join(home, ".bashrc") @@ -140,10 +140,36 @@ def install(): else: print "Please add " + basepath + "to your ~/.bashrc PATH" + print "done." + +def uninstall(): + + print "#0 removing arm toolchain and teensy-tools" + + shutil.rmtree(os.path.join(basepath, "tools")) + + print "#1 updating ~/.bashrc" + + home = os.path.expanduser("~") + bashrc = os.path.join(home, ".bashrc") + + if os.path.exists(bashrc): + import fileinput + delete_line = "PATH=$PATH:" + basepath + "\n" + deleted = False + for l in fileinput.input(bashrc, inplace=1): + if l != delete_line: print l + else: deleted = True + if not deleted: + print "Could not update ~/.bashrc porperly.\nPlease make sure to erase " + basepath + " from your ~/.bashrc PATH" + + print "done." + if __name__ == '__main__': p = OptionParser(); p.add_option('-i', '--install', action="store_true", help="installs t3make00 (~/.bashrc)") + p.add_option('-u', '--uninstall', action="store_true", help="uninstalls t3make00 (~/.bashrc)") p.add_option('-p', '--project', action="store", help="name of the project (defaults to value args[0])") options, args = p.parse_args() @@ -152,6 +178,10 @@ if __name__ == '__main__': install() sys.exit(1) + if options.uninstall: + uninstall() + sys.exit(1) + if not options.project and len(args) == 0: sys.exit("No project specified. Aborting.\nt3make00 --help for usage information."); if len(args) > 1: