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 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] == '-O') {
39         cfg.debugTarget = args[i+1];
40         i++;
41         continue;
42     }
43     if (args[i] == '-t') {
44         cfg.translateJSON = args[i+1];
45         i++;
46         continue;
47     }
48     if (args[i] == '-w') {
49         cfg.tmpDir = args[i+1];
50         i++;
51         continue;
52     }
53     if (args[i] == '-p') {
54         cfg.prefix = args[i+1];
55         i++;
56         continue;
57     }
58  
59     if (args[i] == '-C') {
60         cfg.cleanup = false;
61         continue;
62     }
63     if (args[i] == '-f') {
64         cfg.srcfile = args[i+1];
65         i++;
66         continue;
67     }
68     if (cfg.files.indexOf(args[i]) > -1) {
69         continue; // remove dupes.
70     }
71     cfg.files.push(args[i]);
72 }
73 var pack;
74 try {
75     pack = new Packer(cfg)
76 } catch (e) {
77     print("ERROR " + e.toString());
78     throw e;
79 }
80 if (!pack.target) {
81     print(pack.out);
82 }
83
84