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  * compresses files listed as arguments and outputs result
15  */
16  
17 File            = imports.File.File;
18 Packer          = imports.JSDOC.Packer.Packer;
19
20
21  
22   
23
24 var args = Array.prototype.slice.call(Seed.argv);
25 args.shift(); //seed
26 args.shift(); // pack.js
27 var cfg = {
28     files : [],
29     target : false,
30 }
31
32
33 for(var i =0; i < args.length;i++) {
34     if (args[i] == '-o') {
35         cfg.target = args[i+1];
36         i++;
37         continue;
38     }
39     if (args[i] == '-O') {
40         cfg.debugTarget = args[i+1];
41         i++;
42         continue;
43     }
44     if (args[i] == '-t') {
45         cfg.translateJSON = args[i+1];
46         i++;
47         continue;
48     }
49     if (args[i] == '-w') {
50         cfg.tmpDir = args[i+1];
51         i++;
52         continue;
53     }
54     if (args[i] == '-p') {
55         cfg.prefix = args[i+1];
56         i++;
57         continue;
58     }
59  
60     if (args[i] == '-C') {
61         cfg.cleanup = false;
62         continue;
63     }
64     if (args[i] == '-f') {
65         cfg.srcfile = args[i+1];
66         i++;
67         continue;
68     }
69     if (cfg.files.indexOf(args[i]) > -1) {
70         continue; // remove dupes.
71     }
72     cfg.files.push(args[i]);
73 }
74 var pack;
75 try {
76     pack = new Packer(cfg)
77 } catch (e) {
78     print("ERROR " + e.toString());
79     throw e;
80 }
81 if (!pack.target) {
82     print(pack.out);
83 }
84
85