1 //<script type="text/javascript">
3 * Options management...
6 XObject = imports.XObject.XObject;
7 File = imports.File.File;
12 "--help" : 'Show help', // was h
13 "help": false, // was h;se
16 // configurable settings.. -
17 "usage" : "Usage seed jsdocbuild.js OPTIONS \n",
20 // options get defined like this..
21 "--src" : "source directory (either absolute - starts with "/" or relative " +
22 "- without, in which case it's added to baseDir",
23 "--exclude-src" : 'Ex',
24 "--baseDir" : 'Base Directory (root directory of code)',
25 "--target" : 'Target Directory (where html files go)',
26 "--cacheDirectory": 'Cached Files Directory (or blank to not cache)',
27 "--conf" : 'Read From a Configuration file', // was c. - configuration file.. - parsed with JSON.parse
28 "--templateDir" : 'Template Directory', // was t.
29 // "recurse": false, // was r. - not supported..
30 "--ext" : 'Extension of code files to read (normally js)', // was x.
31 "--publishExt" : 'Extension of html files to write (normally html)',
32 //"private": '', // was p
33 //"allfunctions": '', // was a
34 //"encoding": '', // was e.
35 //"nocode": '', // was n
36 //"out": '', // was o.
37 //"suppress": '', // was s ??? used?
38 "--outputSource" : 'Output the Source code to symbols/src/* (boolean)',
39 //"testmode": '', // was t
41 "--verbose" : 'Show verbose messages', // was v
42 //"disablecache": '', // was C -- not needed? - see if cacheDirectory was set..
43 //"define" : [], // was D.
44 //"handler" : [], // was H -- not supported..
47 // and now the defaults.. (which type can be infered from..)
50 "baseDir" : '', // base directory -
51 "target" : '', // was d. ?? source directory (needed to put temporary files..)
52 "cacheDirectory" : '',
53 "conf" : '', // was c. - configuration file.. - parsed with JSON.parse
54 "templateDir": '', // was t.
55 // "recurse": false, // was r. - not supported..
56 "ext": 'js', // was x.
57 "publishExt" : 'html',
58 "private": '', // was p
59 "allfunctions": '', // was a
60 "encoding": '', // was e.
61 "nocode": '', // was n
63 "suppress": '', // was s ??? used?
64 "outputSource" : true,
65 "testmode": '', // was t
67 "verbose": '', // was v
68 "disablecache": '', // was C
69 "define" : [], // was D.
70 "handler" : [], // was H -- not supported..
77 warn : function(str) {
78 print("Warn: " +str );
80 inform : function(str) {
81 print("Inform: " +str );
83 close : function() { },
84 flush : function() { },
97 // the reset of this is specific to JSDOC - and can not be moved to a generic handler..
100 this.LOG.verbose = this.verbose;
102 if (!this.baseDir) { // should we set this to cwd?
104 name: "ArgumentError",
105 message: "No baseDir specified"
109 // this is most likely to come from the command line..
111 var conf = this.conf[0] == '/' ? this.conf : this.baseDir + '/' + this.conf;
113 XObject.extend(this, JSON.parse(File.read(conf)));;
115 // help ?? -- usage..
117 if (!this.src.length) {
119 name: "ArgumentError",
120 message: "No source directories specified"
123 // append full path to source directories.
127 src.forEach(function(v, i) {
128 if (!v.length || v[0] != '/') {
129 v = _this.baseDir + (v.length ? '/' + v : '');
131 if (!File.exists(v)) {
133 name: "ArgumentError",
134 message: "invalid Source Directory : " + v
141 if (!this.templateDir) {
143 name: "ArgumentError",
144 message: "No templateDir Directory specified"
147 if (this.templateDir[0] !='/') {
148 this.templateDir = this.baseDir + '/' + this.templateDir;
154 name: "ArgumentError",
155 message: "No directory specified"
159 //print(JSON.stringify(this, null,4));
161 // should cacheDirectory be a subdirectory of target??
163 //if (!this.cacheDirectory) {
165 // name: "ArgumentError",
166 // message: "No cacheDirectory specified"
172 * this might be nice as a standard bit of code..
175 parseArgv : function()
178 var args = Array.prototype.slice.call(Seed.argv);
180 args.shift(); // pack.js
182 for(var i =0; i < args.length;i++) {
183 if (args[i].substring(0,2) != '--') {
186 name: "ArgumentError",
187 message: "Unknown argument: " + args[i]
190 var a = args[i].substring(2);
191 if (typeof(this[args[i]]) == 'undefined') {
193 name: "ArgumentError",
194 message: "Unknown argument: " + args[i]
198 if (typeof(this[a]) == 'string') {
203 if (typeof(this[a]) == 'boolean') {
204 if (['false', 'true'].indexOf(args[i+1]) < 0) {
206 name: "ArgumentError",
207 message: "Unknown value for : " + args[i] + ' : ' + args[i+1]
210 this[a] = args[i+1] == 'true';
214 if (typeof(this[a]) == 'object') { // tecnically an array.
216 while(i < args.length)
218 if (args[i].substring(0,2) == '--'){
222 this[a].push(args[i]);
229 name: "ArgumentError",
230 message: "Do not know how to handle: " + a + ' ' + typeof(this[a])
242 if (i.substring(0,2) != '--') {
245 print( i + ' ARG : ' + this[i]);