1 /** 2 * Copyright: Copyright (c) 2011 Jacob Carlborg. All rights reserved. 3 * Authors: Jacob Carlborg 4 * Version: Initial created: May 31, 2011 5 * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0) 6 */ 7 module dvm.commands.List; 8 9 import tango.io.vfs.FileFolder; 10 11 import mambo.core._; 12 import dvm.commands.Command; 13 import Path = dvm.io.Path; 14 15 class List : Command 16 { 17 this (string name, string summary = "") 18 { 19 super(name, summary); 20 } 21 22 this () 23 { 24 super("list", "Show currently installed D compilers."); 25 } 26 27 override void execute () 28 { 29 auto errorMessage = "No installed D compilers"; 30 31 if (!Path.exists(options.path.compilers)) 32 { 33 println(errorMessage); 34 return; 35 } 36 37 scope folder = new FileFolder(options.path.compilers); 38 39 if (folder.self.folders == 0) 40 { 41 println(errorMessage); 42 return; 43 } 44 45 println("Installed D compilers:\n"); 46 47 foreach (file ; folder) 48 println(stripPath(file.toString)); 49 } 50 51 private string stripPath (string name) 52 { 53 return Path.parse(name).file; 54 } 55 }