1 //<script type="text/javascript">
3 * Options management...
5 XObject = import.XObject.XObject;
6 File = import.File.File;
10 // options get defined like this..
11 "--src" : "source directory (either absolute - starts with "/" or relative " +
12 "- without, in which case it's added to baseDir"
13 "--baseDir" : 'Base Directory (root directory of code)',
14 "--target" : 'Target Directory (where html files go)',
15 "--cacheDirectory": 'Cached Files Directory',
16 "--conf" : 'Read From a Configuration file', // was c. - configuration file.. - parsed with JSON.parse
17 "--template" : 'Template Directory', // was t.
18 // "recurse": false, // was r. - not supported..
19 "--ext" : 'Extension of code files to read (normally js)', // was x.
20 "--publishExt" : 'Extension of html files to write (normally html)',
21 //"private": '', // was p
22 //"allfunctions": '', // was a
23 //"encoding": '', // was e.
24 //"nocode": '', // was n
25 //"out": '', // was o.
26 //"suppress": '', // was s ??? used?
27 "--outputSource" : 'Output the Source code to symbols/src/* (boolean)',
28 //"testmode": '', // was t
29 "--help" : 'Show help', // was h
30 "--verbose" : 'Show verbose messages', // was v
31 //"disablecache": '', // was C -- not needed? - see if cacheDirectory was set..
32 //"define" : [], // was D.
33 //"handler" : [], // was H -- not supported..
36 // and now the defaults.. (which type can be infered from..)
38 "baseDir" : '', // base directory -
39 "target" : '', // was d. ?? source directory (needed to put temporary files..)
40 "cacheDirectory" : '',
41 "conf" : '', // was c. - configuration file.. - parsed with JSON.parse
42 "template": '', // was t.
43 // "recurse": false, // was r. - not supported..
44 "ext": 'js', // was x.
45 "publishExt" : 'html',
46 "private": '', // was p
47 "allfunctions": '', // was a
48 "encoding": '', // was e.
49 "nocode": '', // was n
51 "suppress": '', // was s ??? used?
52 "outputSource" : true,
53 "testmode": '', // was t
54 "help": false, // was h;se
55 "verbose": '', // was v
56 "disablecache": '', // was C
57 "define" : [], // was D.
58 "handler" : [], // was H -- not supported..
60 warn : function(str) {
61 print("Warn: " +str );
63 inform : function(str) {
64 print("Inform: " +str );
66 close : function() { },
67 flush : function() { },
79 this.LOG.verbose = this.verbose;
83 XObject.extend(this, JSON.parse(File.read(this.conf)));;
87 if (!this.src.length) {
89 name: "ArgumentError",
90 message: "No source directories specified"
95 name: "ArgumentError",
96 message: "No template specified"
102 name: "ArgumentError",
103 message: "No directory specified"
108 name: "ArgumentError",
109 message: "No baseDir specified"
113 // should cacheDirectory be a subdirectory of target??
115 if (!this.cacheDirectory) {
117 name: "ArgumentError",
118 message: "No cacheDirectory specified"
124 * this might be nice as a standard bit of code..
127 parseArgv : function()
130 var args = Array.prototype.slice.call(Seed.argv);
132 args.shift(); // pack.js
134 for(var i =0; i < args.length;i++) {
135 if (args[i].substring(0,2) != '--') {
138 name: "ArgumentError",
139 message: "Unknown argument: " + args[i]
142 var a = arg[i].substring(2);
143 if (typeof(argTypes[arg[i]]) == 'undefined') {
145 name: "ArgumentError",
146 message: "Unknown argument: " + args[i]
150 if (typeof(this[a]) == 'string') {
155 if (typeof(this[a]) == 'boolean') {
156 if (['false', 'true'].indexOf(args[i+1]) < 0) {
158 name: "ArgumentError",
159 message: "Unknown value for : " + args[i] + ' : ' + args[i+1]
162 this[a] = args[i+1] == 'true';
166 if (typeof(this[a]) == 'object') { // tecnically an array.
168 while(i < args.length)
170 if (args[i].substring(0,2) != '--'){
174 this[a].push(args[i]);
179 name: "ArgumentError",
180 message: "Do not know how to handle: " + a
192 if (i.substring(0,2) != '--') {
195 print( i + ' ARG : ' + this[i]);