PageRenderTime 19ms CodeModel.GetById 13ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/tools/dspec/main.d

http://github.com/wilkie/djehuty
D | 96 lines | 61 code | 26 blank | 9 comment | 2 complexity | 26d69e06ae31621e1a8371f8b116168e MD5 | raw file
 1/*
 2 * dspec.d
 3 *
 4 * This tool will use the parser to parse specifications and produce tests
 5 *
 6 */
 7
 8import io.console;
 9
10import core.main;
11import core.string;
12import core.unicode;
13import core.arguments;
14import core.application;
15import core.definitions;
16
17import filelist;
18import parser;
19
20import parsing.options;
21
22char[] usage = `dspec rev1
23
24USAGE: dspec [-I<PATH>]
25EXAMPLE: dspec -Ispecs/.`;
26
27class Opts : OptionParser {
28
29	mixin Options!(
30		"I", "Specify the path for the specs to be found, recursively",
31		string, "the path",
32
33		"-help", "View help and usage"
34	);
35
36	void onI(string path) {
37		_path = path;
38	}
39
40	void onHelp() {
41		showUsage();
42		Djehuty.application.exit(0);
43	}
44
45	string path() {
46		return _path;
47	}
48
49	string outputPath() {
50		return _outputPath;
51	}
52
53private:
54	string _path = ".";
55	string _outputPath = ".specs";
56}
57
58class Dspec : Application {
59	static this() { new Dspec(); }
60
61	this() {
62		super("djehuty-dspec");
63	}
64
65	override void onApplicationStart() {
66
67		// Parse Options
68		options = new Opts();
69
70		// Interpret arguments
71
72		string path = options.path;
73		string outputPath = options.outputPath;
74
75		Console.putln("Starting on path ", path);
76
77		// Get the list of spec files
78		FileList files = new FileList();
79		if (!(files.fetch(path))) {
80			Console.putln("error");
81			return;
82		}
83
84		Parser parser = new Parser();
85		if (!(parser.parseFiles(path, outputPath, files))) {
86			Console.putln("error");
87			return;
88		}
89
90		Console.putln("Test Routines Built: test.d in ", path);
91	}
92
93private:
94
95	Opts options;
96}