pack.js
[gnome.introspection-doc-generator] / pack.js
1 #!/usr/bin/seed
2 //<script type="text/javascript">
3 /**
4  * packer command line
5  * 
6  * -o Output
7  * -O Output debug file here.
8  * -t Translate json file.
9  * -w Cache / working dir.
10  * -f File to read with a list of source paths / or class names.
11  * -C no cleanup (use with -w if you need are using a cache directory.)
12  * -p prefix for translation md5 generator (directory that files are in, and is removed 
13  *    from path when generating an md5 for the translated name.
14  * -a autoversion - suffixes the latest timestamp eg. Core-100000000.js
15  * -i update index file in output directory.
16  * compresses files listed as arguments and outputs result
17  */
18  
19 File            = imports.File.File;
20 Packer          = imports.JSDOC.Packer.Packer;
21
22
23  
24   
25
26 var args = Array.prototype.slice.call(Seed.argv);
27 args.shift(); //seed
28 args.shift(); // pack.js
29 var cfg = {
30     files : [],
31     target : false,
32     srcfiles : []
33 }
34
35
36 for(var i =0; i < args.length;i++) {
37     if (args[i] == '-o') {
38         cfg.target = args[i+1];
39         i++;
40         continue;
41     }
42     if (args[i] == '-O') {
43         cfg.debugTarget = args[i+1];
44         i++;
45         continue;
46     }
47     if (args[i] == '-t') {
48         cfg.translateJSON = args[i+1];
49         i++;
50         continue;
51     }
52     if (args[i] == '-w') {
53         cfg.tmpDir = args[i+1];
54         i++;
55         continue;
56     }
57     if (args[i] == '-p') {
58         cfg.prefix = args[i+1];
59         i++;
60         continue;
61     }
62  
63     if (args[i] == '-C') {
64         cfg.cleanup = false;
65         continue;
66     }
67     if (args[i] == '-f') {
68         cfg.srcfiles.push(args[i+1]);
69         i++;
70         continue;
71     }
72     if (args[i] == '-i') {
73         cfg.outputIndex = true
74         continue;
75     }
76     if (args[i] == '-a') {
77         cfg.autoVersion= true
78         continue;
79     }
80     if (cfg.files.indexOf(args[i]) > -1) {
81         continue; // remove dupes.
82     }
83     cfg.files.push(args[i]);
84 }
85 var pack;
86 try {
87     pack = new Packer(cfg)
88 } catch (e) {
89     print("ERROR " + e.toString());
90     throw e;
91 }
92 if (!pack.target) {
93     print(pack.out);
94 }
95
96