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  * -t Translate json file.
8  * -w Cache / working dir.
9  * -f File to read with a list of source paths / or class names.
10  * -C no cleanup (use with -w if you need are using a cache directory.)
11  * -p prefix for translation md5 generator (directory that files are in, and is removed 
12  *    from path when generating an md5 for the translated name.
13  *
14  * compresses files listed as arguments and outputs result
15  */
16
17 Packer          = imports['JSDOC/Packer.js'].Packer;
18 File = imports.File.File;
19  
20   
21
22 var args = Array.prototype.slice.call(Seed.argv);
23 args.shift(); //seed
24 args.shift(); // pack.js
25 var cfg = {
26     files : [],
27     target : false,
28 }
29
30
31 for(var i =0; i < args.length;i++) {
32     if (args[i] == '-o') {
33         cfg.target = args[i+1];
34         i++;
35         continue;
36     }
37     if (args[i] == '-t') {
38         cfg.translateJSON = args[i+1];
39         i++;
40         continue;
41     }
42     if (args[i] == '-w') {
43         cfg.tmpDir = args[i+1];
44         i++;
45         continue;
46     }
47     if (args[i] == '-p') {
48         cfg.prefix = args[i+1];
49         i++;
50         continue;
51     }
52     if (args[i] == '-C') {
53         cfg.cleanup = false;
54         continue;
55     }
56     if (args[i] == '-f') {
57         cfg.srcfile = args[i+1];
58         i++;
59         continue;
60     }
61     if (cfg.files.indexOf(args[i]) > -1) {
62         continue; // remove dupes.
63     }
64     cfg.files.push(args[i]);
65 }
66 var pack;
67 try {
68     pack = new Packer(cfg)
69 } catch (e) {
70     print("ERROR " + e.toString());
71     throw e;
72 }
73 if (!pack.target) {
74     print(pack.out);
75 }
76
77