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 tango.io.device.File;
10 import tango.text.Util;
11 
12 import dvm.commands.Command;
13 import mambo.core._;
14 import Path = dvm.io.Path;
15 import dvm.util._;
16 
17 class Uninstall : Command
18 {
19     private string installPath_;
20 
21     this (string name, string summary = "")
22     {
23         super(name, summary);
24     }
25 
26     this ()
27     {
28         super("uninstall", "Uninstall one or many D compilers.");
29     }
30 
31     override void execute ()
32     {
33         println("Uninstalling dmd-", args.first);
34         removeFiles;
35     }
36 
37 private:
38 
39     void removeFiles ()
40     {
41         verbose("Removing files:");
42 
43         auto dmd = "dmd-" ~ args.first;
44 
45         removeFile(Path.join(options.path.compilers, dmd).assumeUnique);
46         removeFile(Path.join(options.path.env, dmd).assumeUnique);
47         removeFile(Path.join(options.path.dvm, options.path.bin, dmd).assumeUnique);
48     }
49 
50     void removeFile (string path)
51     {
52         if (!Path.exists(path))
53             return;
54 
55         verbose(options.indentation, path);
56         Path.remove(path, true);
57     }
58 }