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