1 //<script type="text/javascript">
3 * Options management...
7 XObject = imports.XObject.XObject;
8 File = imports.File.File;
17 "--help" : 'Show help', // was h
18 "help": false, // was h;se
21 // configurable settings.. -
22 "usage" : "Usage seed jsdocbuild.js OPTIONS \n",
25 // options get defined like this..
26 "--src" : "source directory (either absolute - starts with "/" or relative " +
27 "- without, in which case it's added to baseDir",
28 "--exclude-src" : 'Ex',
29 "--baseDir" : 'Base Directory (root directory of code)',
30 "--target" : 'Target Directory (where html files go)',
31 "--cacheDirectory": 'Cached Files Directory (or blank to not cache)',
32 "--conf" : 'Read From a Configuration file', // was c. - configuration file.. - parsed with JSON.parse
33 "--templateDir" : 'Template Directory', // was t.
34 // "recurse": false, // was r. - not supported..
35 "--ext" : 'Extension of code files to read (normally js)', // was x.
36 "--publishExt" : 'Extension of html files to write (normally html)',
37 //"private": '', // was p
38 //"allfunctions": '', // was a
39 //"encoding": '', // was e.
40 //"nocode": '', // was n
41 //"out": '', // was o.
42 //"suppress": '', // was s ??? used?
43 "--outputSource" : 'Output the Source code to symbols/src/* (boolean)',
44 //"testmode": '', // was t
46 "--verbose" : 'Show verbose messages', // was v
47 //"disablecache": '', // was C -- not needed? - see if cacheDirectory was set..
48 //"define" : [], // was D.
49 //"handler" : [], // was H -- not supported..
52 // and now the defaults.. (which type can be infered from..)
55 "baseDir" : '', // base directory -
56 "target" : '', // was d. ?? source directory (needed to put temporary files..)
57 "cacheDirectory" : '',
58 "conf" : '', // was c. - configuration file.. - parsed with JSON.parse
59 "templateDir": '', // was t.
60 // "recurse": false, // was r. - not supported..
61 "ext": 'js', // was x.
62 "publishExt" : 'html',
63 "private": '', // was p
64 "allfunctions": '', // was a
65 "encoding": '', // was e.
66 "nocode": '', // was n
68 "suppress": '', // was s ??? used?
69 "outputSource" : true,
70 "testmode": '', // was t
72 "verbose": '', // was v
73 "disablecache": '', // was C
74 "define" : [], // was D.
75 "handler" : [], // was H -- not supported..
82 warn : function(str) {
83 print("Warn: " +str );
85 inform : function(str) {
86 print("Inform: " +str );
88 close : function() { },
89 flush : function() { },
102 // the reset of this is specific to JSDOC - and can not be moved to a generic handler..
105 this.LOG.verbose = this.verbose;
107 if (!this.baseDir) { // should we set this to cwd?
109 name: "ArgumentError",
110 message: "No baseDir specified"
114 // this is most likely to come from the command line..
116 var conf = this.conf[0] == '/' ? this.conf : this.baseDir + '/' + this.conf;
118 XObject.extend(this, JSON.parse(File.read(conf)));;
120 // help ?? -- usage..
122 if (!this.src.length) {
124 name: "ArgumentError",
125 message: "No source directories specified"
128 // append full path to source directories.
132 src.forEach(function(v, i) {
133 if (!v.length || v[0] != '/') {
134 v = _this.baseDir + (v.length ? '/' + v : '');
136 if (!File.exists(v)) {
138 name: "ArgumentError",
139 message: "invalid Source Directory : " + v
146 if (!this.templateDir) {
148 name: "ArgumentError",
149 message: "No templateDir Directory specified"
152 if (this.templateDir[0] !='/') {
153 this.templateDir = this.baseDir + '/' + this.templateDir;
159 name: "ArgumentError",
160 message: "No directory specified"
164 //print(JSON.stringify(this, null,4));
166 // should cacheDirectory be a subdirectory of target??
168 //if (!this.cacheDirectory) {
170 // name: "ArgumentError",
171 // message: "No cacheDirectory specified"
177 * this might be nice as a standard bit of code..
180 parseArgv : function()
183 var args = Array.prototype.slice.call(Seed.argv);
185 args.shift(); // pack.js
187 for(var i =0; i < args.length;i++) {
188 if (args[i].substring(0,2) != '--') {
191 name: "ArgumentError",
192 message: "Unknown argument: " + args[i]
195 var a = args[i].substring(2);
196 if (typeof(this[args[i]]) == 'undefined') {
198 name: "ArgumentError",
199 message: "Unknown argument: " + args[i]
203 if (typeof(this[a]) == 'string') {
208 if (typeof(this[a]) == 'boolean') {
209 if (['false', 'true'].indexOf(args[i+1]) < 0) {
211 name: "ArgumentError",
212 message: "Unknown value for : " + args[i] + ' : ' + args[i+1]
215 this[a] = args[i+1] == 'true';
219 if (typeof(this[a]) == 'object') { // tecnically an array.
221 while(i < args.length)
223 if (args[i].substring(0,2) == '--'){
227 this[a].push(args[i]);
234 name: "ArgumentError",
235 message: "Do not know how to handle: " + a + ' ' + typeof(this[a])
247 if (i.substring(0,2) != '--') {
250 print( i + ' ARG : ' + this[i]);