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 "--baseDir" : 'Base Directory (root directory of code)',
23 "--target" : 'Target Directory (where html files go)',
24 "--cacheDirectory": 'Cached Files Directory',
25 "--conf" : 'Read From a Configuration file', // was c. - configuration file.. - parsed with JSON.parse
26 "--template" : 'Template Directory', // was t.
27 // "recurse": false, // was r. - not supported..
28 "--ext" : 'Extension of code files to read (normally js)', // was x.
29 "--publishExt" : 'Extension of html files to write (normally html)',
30 //"private": '', // was p
31 //"allfunctions": '', // was a
32 //"encoding": '', // was e.
33 //"nocode": '', // was n
34 //"out": '', // was o.
35 //"suppress": '', // was s ??? used?
36 "--outputSource" : 'Output the Source code to symbols/src/* (boolean)',
37 //"testmode": '', // was t
39 "--verbose" : 'Show verbose messages', // was v
40 //"disablecache": '', // was C -- not needed? - see if cacheDirectory was set..
41 //"define" : [], // was D.
42 //"handler" : [], // was H -- not supported..
45 // and now the defaults.. (which type can be infered from..)
47 "baseDir" : '', // base directory -
48 "target" : '', // was d. ?? source directory (needed to put temporary files..)
49 "cacheDirectory" : '',
50 "conf" : '', // was c. - configuration file.. - parsed with JSON.parse
51 "template": '', // was t.
52 // "recurse": false, // was r. - not supported..
53 "ext": 'js', // was x.
54 "publishExt" : 'html',
55 "private": '', // was p
56 "allfunctions": '', // was a
57 "encoding": '', // was e.
58 "nocode": '', // was n
60 "suppress": '', // was s ??? used?
61 "outputSource" : true,
62 "testmode": '', // was t
64 "verbose": '', // was v
65 "disablecache": '', // was C
66 "define" : [], // was D.
67 "handler" : [], // was H -- not supported..
69 warn : function(str) {
70 print("Warn: " +str );
72 inform : function(str) {
73 print("Inform: " +str );
75 close : function() { },
76 flush : function() { },
89 // the reset of this is specific to JSDOC - and can not be moved to a generic handler..
92 this.LOG.verbose = this.verbose;
94 if (!this.baseDir) { // should we set this to cwd?
96 name: "ArgumentError",
97 message: "No baseDir specified"
101 // this is most likely to come from the command line..
103 var conf = this.conf[0] == '/' ? this.conf : this.baseDir + '/' + this.conf;
104 print("loading : " + conf);
105 print(JSON.stringify(JSON.parse(File.read(conf)), null,4);
106 XObject.extend(this, JSON.parse(File.read(conf)));;
108 // help ?? -- usage..
110 if (!this.src.length) {
112 name: "ArgumentError",
113 message: "No source directories specified"
116 // append full path to source directories.
118 this.src.forEach(function(v, i) {
120 this.src[i] = _this.baseDir + '/' + v;
122 if (File.isDirectory(this.src[i])) {
124 name: "ArgumentError",
125 message: "invalid Source Directory : " + v
131 if (!this.template) {
133 name: "ArgumentError",
134 message: "No template Directory specified"
140 name: "ArgumentError",
141 message: "No directory specified"
146 // should cacheDirectory be a subdirectory of target??
148 //if (!this.cacheDirectory) {
150 // name: "ArgumentError",
151 // message: "No cacheDirectory specified"
157 * this might be nice as a standard bit of code..
160 parseArgv : function()
163 var args = Array.prototype.slice.call(Seed.argv);
165 args.shift(); // pack.js
167 for(var i =0; i < args.length;i++) {
168 if (args[i].substring(0,2) != '--') {
171 name: "ArgumentError",
172 message: "Unknown argument: " + args[i]
175 var a = args[i].substring(2);
176 if (typeof(this[args[i]]) == 'undefined') {
178 name: "ArgumentError",
179 message: "Unknown argument: " + args[i]
183 if (typeof(this[a]) == 'string') {
188 if (typeof(this[a]) == 'boolean') {
189 if (['false', 'true'].indexOf(args[i+1]) < 0) {
191 name: "ArgumentError",
192 message: "Unknown value for : " + args[i] + ' : ' + args[i+1]
195 this[a] = args[i+1] == 'true';
199 if (typeof(this[a]) == 'object') { // tecnically an array.
201 while(i < args.length)
203 if (args[i].substring(0,2) != '--'){
207 this[a].push(args[i]);
212 name: "ArgumentError",
213 message: "Do not know how to handle: " + a
225 if (i.substring(0,2) != '--') {
228 print( i + ' ARG : ' + this[i]);