1 // SemiTwist D Tools 2 // STManage: STStart 3 // Written in the D programming language. 4 5 /++ 6 Author: 7 $(WEB www.semitwist.com, Nick Sabalausky) 8 9 IGNORE THIS APP FOR NOW, IT IS NOT USABLE YET 10 +/ 11 12 module semitwist.apps.stmanage.ststart.main; 13 14 import semitwist.cmd.all; 15 16 void main(){} 17 18 /+ 19 enum main_d_src = 20 `// {0} 21 // Written in the D programming language 22 23 module {0}.main; 24 25 import tango.io.Stdout; 26 27 int main(string[] args) 28 {{ 29 Stdout("{0}: Hello World!").newline; 30 return 0; 31 } 32 `; 33 34 void main(string[] args) 35 { 36 // Prompt stuff 37 enum promptOverwrite = "Delete and overwrite (yes/no)? "; 38 enum msgFailedYesNo = "You must enter 'yes' or 'no', not '%s'."; 39 bool acceptYesNo(string input) 40 { 41 return input=="yes" || input=="no"; 42 } 43 44 // Config 45 // auto rootDirs = ["trunk"[],"branches","tags","downloads"]; 46 // auto trunkDirs = ["bin"[],"obj","src"]; 47 48 // Header 49 Stdout("SemiTwist Library: semitwist.cmd sample:").newline; 50 Stdout("Creating a new subversion repository").newline; 51 Stdout.newline; 52 53 // Do Checks 54 string projectName; 55 if(args.length > 1) 56 projectName = args[1]; 57 else 58 projectName = cmd.prompt("Enter project name: "); 59 60 if(cmd.dir.folder(projectName).exists) 61 { 62 Stdout("Project already exists").newline; 63 auto input = cmd.prompt(promptOverwrite, &acceptYesNo, msgFailedYesNo); 64 if(input == "no") 65 return; 66 cmd.dir.folder(projectName).open.clear; 67 return; 68 } 69 70 // Set up dirs/files for initial commit 71 void createDirs(string[] dirs) 72 { 73 foreach(string dir; dirs) 74 cmd.dir.folder(dir).create; 75 } 76 77 auto originalDir = cmd.dir; 78 cmd.dir.folder(projectName).create; 79 80 cmd.dir = projectName; 81 createDirs(["trunk"[],"branches","tags","downloads"]); 82 83 cmd.dir = "trunk"; 84 createDirs(["bin"[],"obj","src"]); 85 86 cmd.dir = "bin"; 87 createDirs(["debug"[],"release"]); 88 89 cmd.dir = "../src"; 90 cmd.dir.folder(projectName).create; 91 92 cmd.dir = projectName; 93 auto main_d = cmd.dir.file("main.d").create.output; 94 main_d.write(main_d_src.sformat(projectName)); 95 main_d.close; 96 // cmd.dir.file("main.d").open.output.write("hello").close; 97 // cmd.dir.file("main.d").output.copy("hello").close; 98 99 // cmd.dir = originalDir.toString~"/"~projectName; 100 // cmd.dir = "%s/%s".format(originalDir, projectName); 101 // auto allCreated = cmd.dir.tree; 102 cmd.dir = originalDir; 103 auto allCreated = cmd.dir.folder(projectName).open.tree; 104 writefln("Created %s bytes in %s folder(s) and %s file(s)", 105 allCreated.bytes, allCreated.folders, allCreated.files); 106 107 // cmd.dir = originalDir; 108 } 109 +/