-
Notifications
You must be signed in to change notification settings - Fork 7
/
abc2odt
executable file
·72 lines (61 loc) · 1.44 KB
/
abc2odt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#! /usr/bin/env node
// abc2odt
// define the system functions
var sep = require('path').sep
function usage() {
abc2svg.printErr('ABC to ODT translator with\
abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
abc2odt [g_options] ABC_file [f_options] [ABC_file [f_options]]* [-o output_file]\n\
Arguments:\n\
g_options global ABC options\n\
ABC_file ABC file\n\
f_options file options\n\
output_file output file - default is "./abc.odt"')
abc2svg.quit()
}
// load the abc2svg core
var m = require("abc2svg/abc2svg-1");
global.abc2svg = m.abc2svg;
global.Abc = m.Abc;
// interpreter specific functions
abc2svg.print = function(str) {
process.stdout.write(str + '\n')
}
abc2svg.printErr = function(str) {
process.stderr.write(str + '\n')
}
abc2svg.quit = function() {
process.exit(1)
}
abc2svg.readFile = function(fname) {
var fs = require("fs")
return fs.readFileSync(fname).toString()
}
abc2svg.loadjs = function(fn, relay, onerror) {
try {
var geval = eval;
geval(abc2svg.readFile(__dirname + sep + fn))
if (relay)
relay()
} catch(e) {
if (onerror)
onerror()
else
abc2svg.printErr('Cannot read file ' + fn)
}
}
// load the command line
m = require("abc2svg/cmdline");
global.abc = m.abc;
global.user = m.user;
global.abc_cmd = m.abc_cmd
// load the ODT backend
require("abc2svg/toodt");
// main
var args = process.argv
if (!args[2])
usage();
args.shift();
args.shift()
abc_cmd("abc2odt", args)