3 XObject = imports.XObject.XObject;
4 File = imports.File.File;
9 * Options management...
13 * Deprecated at present..
18 "--help" : 'Show help', // was h
19 "help": false, // was h;se
22 // configurable settings.. -
23 "usage" : "Usage seed jsdocbuild.js OPTIONS \n",
26 // options get defined like this..
27 "--src" : "source directory (either absolute - starts with \"/\" or relative " +
28 "- without, in which case it's added to baseDir",
29 "--exclude-src" : 'Ex',
30 "--baseDir" : 'Base Directory (root directory of code)',
31 "--target" : 'Target Directory (where html files go)',
32 "--cacheDirectory": 'Cached Files Directory (or blank to not cache)',
33 "--conf" : 'Read From a Configuration file', // was c. - configuration file.. - parsed with JSON.parse
34 "--templateDir" : 'Template Directory', // was t.
35 // "recurse": false, // was r. - not supported..
36 "--ext" : 'Extension of code files to read (normally js)', // was x.
37 "--publishExt" : 'Extension of html files to write (normally html)',
38 //"private": '', // was p
39 //"allfunctions": '', // was a
40 //"encoding": '', // was e.
41 //"nocode": '', // was n
42 //"out": '', // was o.
43 //"suppress": '', // was s ??? used?
44 "--outputSource" : 'Output the Source code to symbols/src/* (boolean)',
45 //"testmode": '', // was t
47 "--verbose" : 'Show verbose messages', // was v
48 //"disablecache": '', // was C -- not needed? - see if cacheDirectory was set..
49 //"define" : [], // was D.
50 //"handler" : [], // was H -- not supported..
53 // and now the defaults.. (which type can be infered from..)
56 "baseDir" : '', // base directory -
57 "target" : '', // was d. ?? source directory (needed to put temporary files..)
58 "cacheDirectory" : '',
59 "conf" : '', // was c. - configuration file.. - parsed with JSON.parse
60 "templateDir": '', // was t.
61 // "recurse": false, // was r. - not supported..
62 "ext": 'js', // was x.
63 "publishExt" : 'html',
64 "private": '', // was p
65 "allfunctions": '', // was a
66 "encoding": '', // was e.
67 "nocode": '', // was n
69 "suppress": '', // was s ??? used?
70 "outputSource" : true,
71 "testmode": '', // was t
73 "verbose": '', // was v
74 "disablecache": '', // was C
75 "define" : [], // was D.
76 "handler" : [], // was H -- not supported..
83 warn : function(str) {
84 print("Warn: " +str );
86 inform : function(str) {
87 print("Inform: " +str );
89 close : function() { },
90 flush : function() { },
103 // the reset of this is specific to JSDOC - and can not be moved to a generic handler..
106 this.LOG.verbose = this.verbose;
108 if (!this.baseDir) { // should we set this to cwd?
110 name: "ArgumentError",
111 message: "No baseDir specified"
115 // this is most likely to come from the command line..
117 var conf = this.conf[0] == '/' ? this.conf : this.baseDir + '/' + this.conf;
119 XObject.extend(this, JSON.parse(File.read(conf)));;
121 // help ?? -- usage..
123 if (!this.src.length) {
125 name: "ArgumentError",
126 message: "No source directories specified"
129 // append full path to source directories.
133 src.forEach(function(v, i) {
134 if (!v.length || v[0] != '/') {
135 v = _this.baseDir + (v.length ? '/' + v : '');
137 if (!File.exists(v)) {
139 name: "ArgumentError",
140 message: "invalid Source Directory : " + v
147 if (!this.templateDir) {
149 name: "ArgumentError",
150 message: "No templateDir Directory specified"
153 if (this.templateDir[0] !='/') {
154 this.templateDir = this.baseDir + '/' + this.templateDir;
160 name: "ArgumentError",
161 message: "No directory specified"
165 //print(JSON.stringify(this, null,4));
167 // should cacheDirectory be a subdirectory of target??
169 //if (!this.cacheDirectory) {
171 // name: "ArgumentError",
172 // message: "No cacheDirectory specified"
178 * this might be nice as a standard bit of code..
181 parseArgv : function()
184 var args = Array.prototype.slice.call(Seed.argv);
186 args.shift(); // pack.js
188 for(var i =0; i < args.length;i++) {
189 if (args[i].substring(0,2) != '--') {
192 name: "ArgumentError",
193 message: "Unknown argument: " + args[i]
196 var a = args[i].substring(2);
197 if (typeof(this[args[i]]) == 'undefined') {
199 name: "ArgumentError",
200 message: "Unknown argument: " + args[i]
204 if (typeof(this[a]) == 'string') {
209 if (typeof(this[a]) == 'boolean') {
210 if (['false', 'true'].indexOf(args[i+1]) < 0) {
212 name: "ArgumentError",
213 message: "Unknown value for : " + args[i] + ' : ' + args[i+1]
216 this[a] = args[i+1] == 'true';
220 if (typeof(this[a]) == 'object') { // tecnically an array.
222 while(i < args.length)
224 if (args[i].substring(0,2) == '--'){
228 this[a].push(args[i]);
235 name: "ArgumentError",
236 message: "Do not know how to handle: " + a + ' ' + typeof(this[a])
248 if (i.substring(0,2) != '--') {
251 print( i + ' ARG : ' + this[i]);