1 //<script type="text/javascript">
3 * Options management...
5 XObject = imports.XObject.XObject;
6 File = imports.File.File;
11 "--help" : 'Show help', // was h
12 "help": false, // was h;se
15 // configurable settings.. -
16 "usage" : "Usage seed jsdocbuild.js OPTIONS \n",
19 // options get defined like this..
20 "--src" : "source directory (either absolute - starts with "/" or relative " +
21 "- without, in which case it's added to baseDir",
22 "--exclude-src" : 'Ex',
23 "--baseDir" : 'Base Directory (root directory of code)',
24 "--target" : 'Target Directory (where html files go)',
25 "--cacheDirectory": 'Cached Files Directory (or blank to not cache)',
26 "--conf" : 'Read From a Configuration file', // was c. - configuration file.. - parsed with JSON.parse
27 "--templateDir" : 'Template Directory', // was t.
28 // "recurse": false, // was r. - not supported..
29 "--ext" : 'Extension of code files to read (normally js)', // was x.
30 "--publishExt" : 'Extension of html files to write (normally html)',
31 //"private": '', // was p
32 //"allfunctions": '', // was a
33 //"encoding": '', // was e.
34 //"nocode": '', // was n
35 //"out": '', // was o.
36 //"suppress": '', // was s ??? used?
37 "--outputSource" : 'Output the Source code to symbols/src/* (boolean)',
38 //"testmode": '', // was t
40 "--verbose" : 'Show verbose messages', // was v
41 //"disablecache": '', // was C -- not needed? - see if cacheDirectory was set..
42 //"define" : [], // was D.
43 //"handler" : [], // was H -- not supported..
46 // and now the defaults.. (which type can be infered from..)
49 "baseDir" : '', // base directory -
50 "target" : '', // was d. ?? source directory (needed to put temporary files..)
51 "cacheDirectory" : '',
52 "conf" : '', // was c. - configuration file.. - parsed with JSON.parse
53 "templateDir": '', // was t.
54 // "recurse": false, // was r. - not supported..
55 "ext": 'js', // was x.
56 "publishExt" : 'html',
57 "private": '', // was p
58 "allfunctions": '', // was a
59 "encoding": '', // was e.
60 "nocode": '', // was n
62 "suppress": '', // was s ??? used?
63 "outputSource" : true,
64 "testmode": '', // was t
66 "verbose": '', // was v
67 "disablecache": '', // was C
68 "define" : [], // was D.
69 "handler" : [], // was H -- not supported..
76 warn : function(str) {
77 print("Warn: " +str );
79 inform : function(str) {
80 print("Inform: " +str );
82 close : function() { },
83 flush : function() { },
96 // the reset of this is specific to JSDOC - and can not be moved to a generic handler..
99 this.LOG.verbose = this.verbose;
101 if (!this.baseDir) { // should we set this to cwd?
103 name: "ArgumentError",
104 message: "No baseDir specified"
108 // this is most likely to come from the command line..
110 var conf = this.conf[0] == '/' ? this.conf : this.baseDir + '/' + this.conf;
112 XObject.extend(this, JSON.parse(File.read(conf)));;
114 // help ?? -- usage..
116 if (!this.src.length) {
118 name: "ArgumentError",
119 message: "No source directories specified"
122 // append full path to source directories.
126 src.forEach(function(v, i) {
127 if (!v.length || v[0] != '/') {
128 v = _this.baseDir + (v.length ? '/' + v : '');
130 if (!File.exists(v)) {
132 name: "ArgumentError",
133 message: "invalid Source Directory : " + v
140 if (!this.templateDir) {
142 name: "ArgumentError",
143 message: "No templateDir Directory specified"
146 if (this.templateDir[0] !='/') {
147 this.templateDir = this.baseDir + '/' + this.templateDir;
153 name: "ArgumentError",
154 message: "No directory specified"
158 //print(JSON.stringify(this, null,4));
160 // should cacheDirectory be a subdirectory of target??
162 //if (!this.cacheDirectory) {
164 // name: "ArgumentError",
165 // message: "No cacheDirectory specified"
171 * this might be nice as a standard bit of code..
174 parseArgv : function()
177 var args = Array.prototype.slice.call(Seed.argv);
179 args.shift(); // pack.js
181 for(var i =0; i < args.length;i++) {
182 if (args[i].substring(0,2) != '--') {
185 name: "ArgumentError",
186 message: "Unknown argument: " + args[i]
189 var a = args[i].substring(2);
190 if (typeof(this[args[i]]) == 'undefined') {
192 name: "ArgumentError",
193 message: "Unknown argument: " + args[i]
197 if (typeof(this[a]) == 'string') {
202 if (typeof(this[a]) == 'boolean') {
203 if (['false', 'true'].indexOf(args[i+1]) < 0) {
205 name: "ArgumentError",
206 message: "Unknown value for : " + args[i] + ' : ' + args[i+1]
209 this[a] = args[i+1] == 'true';
213 if (typeof(this[a]) == 'object') { // tecnically an array.
215 while(i < args.length)
217 if (args[i].substring(0,2) == '--'){
221 this[a].push(args[i]);
228 name: "ArgumentError",
229 message: "Do not know how to handle: " + a + ' ' + typeof(this[a])
241 if (i.substring(0,2) != '--') {
244 print( i + ' ARG : ' + this[i]);