1 /** 2 * Copyright: Copyright (c) 2011 Jacob Carlborg. All rights reserved. 3 * Authors: Jacob Carlborg 4 * Version: Initial created: Jun 3, 2011 5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) 6 */ 7 module dvm.commands.Uninstall; 8 9 import std.exception : assumeUnique; 10 import std.stdio : writeln; 11 12 import tango.io.device.File; 13 import tango.text.Util; 14 15 import dvm.commands.Command; 16 import Path = dvm.io.Path; 17 import dvm.util._; 18 19 class Uninstall : Command 20 { 21 private string installPath_; 22 23 this (string name, string summary = "") 24 { 25 super(name, summary); 26 } 27 28 this () 29 { 30 super("uninstall", "Uninstall one or many D compilers."); 31 } 32 33 override void execute () 34 { 35 writeln("Uninstalling dmd-", args.first); 36 removeFiles; 37 } 38 39 private: 40 41 void removeFiles () 42 { 43 verbose("Removing files:"); 44 45 auto dmd = "dmd-" ~ args.first; 46 47 removeFile(Path.join(options.path.compilers, dmd).assumeUnique); 48 removeFile(Path.join(options.path.env, dmd).assumeUnique); 49 removeFile(Path.join(options.path.dvm, options.path.bin, dmd).assumeUnique); 50 } 51 52 void removeFile (string path) 53 { 54 if (!Path.exists(path)) 55 return; 56 57 verbose(options.indentation, path); 58 Path.remove(path, true); 59 } 60 }