1 //<script type="text/javascript">
3 * Options management...
5 XObject = import.XObject.XObject;
6 File = import.File.File;
10 // options get defined like this..
11 "--src" : "source directory (either absolute - starts with "/" or relative " +
12 "- without, in which case it's added to baseDir"
13 "--baseDir" : 'Base Directory (root directory of code)',
14 "--target" : 'Target Directory (where html files go)',
15 "--cacheDirectory": 'Cached Files Directory',
16 "--conf" : 'Read From a Configuration file', // was c. - configuration file.. - parsed with JSON.parse
17 "--template" : 'Template Directory', // was t.
18 // "recurse": false, // was r. - not supported..
19 "--ext" : 'Extension of code files to read (normally js)', // was x.
20 "--publishExt" : 'Extension of html files to write (normally html)',
21 //"private": '', // was p
22 //"allfunctions": '', // was a
23 //"encoding": '', // was e.
24 //"nocode": '', // was n
25 //"out": '', // was o.
26 //"suppress": '', // was s ??? used?
27 "--outputSource" : 'Output the Source code to symbols/src/* (boolean)',
28 //"testmode": '', // was t
29 "--help" : 'Show help', // was h
30 "--verbose" : 'Show verbose messages', // was v
31 //"disablecache": '', // was C -- not needed? - see if cacheDirectory was set..
32 //"define" : [], // was D.
33 //"handler" : [], // was H -- not supported..
36 // and now the defaults.. (which type can be infered from..)
38 "baseDir" : '', // base directory -
39 "target" : '', // was d. ?? source directory (needed to put temporary files..)
40 "cacheDirectory" : '',
41 "conf" : '', // was c. - configuration file.. - parsed with JSON.parse
42 "template": '', // was t.
43 // "recurse": false, // was r. - not supported..
44 "ext": 'js', // was x.
45 "publishExt" : 'html',
46 "private": '', // was p
47 "allfunctions": '', // was a
48 "encoding": '', // was e.
49 "nocode": '', // was n
51 "suppress": '', // was s ??? used?
52 "outputSource" : true,
53 "testmode": '', // was t
54 "help": false, // was h;se
55 "verbose": '', // was v
56 "disablecache": '', // was C
57 "define" : [], // was D.
58 "handler" : [], // was H -- not supported..
60 warn : function(str) {
61 print("Warn: " +str );
63 inform : function(str) {
64 print("Inform: " +str );
66 close : function() { },
67 flush : function() { },
80 // the reset of this is specific to JSDOC - and can not be moved to a generic handler..
83 this.LOG.verbose = this.verbose;
85 // this is most likely to come from the command line..
87 XObject.extend(this, JSON.parse(File.read(this.conf)));;
91 if (!this.src.length) {
93 name: "ArgumentError",
94 message: "No source directories specified"
99 name: "ArgumentError",
100 message: "No template specified"
106 name: "ArgumentError",
107 message: "No directory specified"
112 name: "ArgumentError",
113 message: "No baseDir specified"
117 // should cacheDirectory be a subdirectory of target??
119 if (!this.cacheDirectory) {
121 name: "ArgumentError",
122 message: "No cacheDirectory specified"
128 * this might be nice as a standard bit of code..
131 parseArgv : function()
134 var args = Array.prototype.slice.call(Seed.argv);
136 args.shift(); // pack.js
138 for(var i =0; i < args.length;i++) {
139 if (args[i].substring(0,2) != '--') {
142 name: "ArgumentError",
143 message: "Unknown argument: " + args[i]
146 var a = arg[i].substring(2);
147 if (typeof(argTypes[arg[i]]) == 'undefined') {
149 name: "ArgumentError",
150 message: "Unknown argument: " + args[i]
154 if (typeof(this[a]) == 'string') {
159 if (typeof(this[a]) == 'boolean') {
160 if (['false', 'true'].indexOf(args[i+1]) < 0) {
162 name: "ArgumentError",
163 message: "Unknown value for : " + args[i] + ' : ' + args[i+1]
166 this[a] = args[i+1] == 'true';
170 if (typeof(this[a]) == 'object') { // tecnically an array.
172 while(i < args.length)
174 if (args[i].substring(0,2) != '--'){
178 this[a].push(args[i]);
183 name: "ArgumentError",
184 message: "Do not know how to handle: " + a
196 if (i.substring(0,2) != '--') {
199 print( i + ' ARG : ' + this[i]);