abc2svg
Check-in [d06b70d6e2]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:batch: apply the command line options to the next ABC file !! compatibility !!
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: d06b70d6e2b9ba138052984c36d0f5cfe4f2902d
User & Date: jef 2020-02-29 11:40:13.617
Context
2020-02-29
14:52
batch: fix: crash when only one argument in the command line since last commit ... (check-in: d74c65838b user: jef tags: trunk)
11:40
batch: apply the command line options to the next ABC file !! compatibility !! ... (check-in: d06b70d6e2 user: jef tags: trunk)
2020-02-27
18:47
core: fix: bad output when page formatting and %%newpage inside tune ... (check-in: e1853a4ac5 user: jef tags: trunk)
Changes
Unified Diff Ignore Whitespace Patch
Changes to abc2odt.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#! /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;











|

|

<







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15

16
17
18
19
20
21
22
#! /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 [options] ABC_file [[options] ABC_file]* [options] [-o output_file]\n\
Arguments:\n\
  options     ABC options (the last options are moved before the last file)\n\
  ABC_file    ABC file\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;
Changes to abc2svg.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env node

// abc2svg with native nodeJS

// define the system functions
    var	sep = require('path').sep

function usage() {
	abc2svg.printErr('ABC translator with Node.js\
 and abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
  abc2svg [script.js] [g_options] ABC_file [f_options] [ABC_file [f_options]]*\n\
Arguments:\n\
  script.js  generation script to load - default: toxhtml.js (XHTML+SVG)\n\
  g_options  global ABC options\n\
  ABC_file   ABC file\n\
  f_options  file options')
	abc2svg.quit()
}

// load the abc2svg core
var m = require("abc2svg/abc2svg-1");
global.abc2svg = m.abc2svg;
global.Abc = m.Abc;











|


|
|
<







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16

17
18
19
20
21
22
23
#!/usr/bin/env node

// abc2svg with native nodeJS

// define the system functions
    var	sep = require('path').sep

function usage() {
	abc2svg.printErr('ABC translator with Node.js\
 and abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
  abc2svg [script.js] [options] ABC_file [[options] ABC_file]* [options]\n\
Arguments:\n\
  script.js  generation script to load - default: toxhtml.js (XHTML+SVG)\n\
  options    ABC options (the last options are moved before the last file)\n\
  ABC_file   ABC file')

	abc2svg.quit()
}

// load the abc2svg core
var m = require("abc2svg/abc2svg-1");
global.abc2svg = m.abc2svg;
global.Abc = m.Abc;
Changes to abcjs24.
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
	}
	if (typeof abc2svg.abc_init != 'function')
		loadRelativeToScript("toxhtml.js")
	if (!args[0]) {
		printErr('ABC translator with js24 (SpiderMonkey)\
 and abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
  abcjs24 [script.js] [g_options] ABC_file [f_options] [ABC_file [f_options]]*\n\
Arguments:\n\
  script.js  generation script to load - default: toxhtml.js (XHTML+SVG)\n\
  g_options  global ABC options\n\
  ABC_file   ABC file\n\
  f_options  file options')
		quit()
	}
	abc_cmd("abcjs24", args)







|


|
|
<



42
43
44
45
46
47
48
49
50
51
52
53

54
55
56
	}
	if (typeof abc2svg.abc_init != 'function')
		loadRelativeToScript("toxhtml.js")
	if (!args[0]) {
		printErr('ABC translator with js24 (SpiderMonkey)\
 and abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
  abcjs24 [script.js] [options] ABC_file [[options] ABC_file]* [options]\n\
Arguments:\n\
  script.js  generation script to load - default: toxhtml.js (XHTML+SVG)\n\
  options    ABC options (the last options are moved before the last file)\n\
  ABC_file   ABC file')

		quit()
	}
	abc_cmd("abcjs24", args)
Changes to abcjs52.
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
	}
	if (typeof abc2svg.abc_init != 'function')
		loadRelativeToScript("toxhtml.js")
	if (!args[0]) {
		printErr('ABC translator with js52 (SpiderMonkey)\
 and abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
  abcjs52 [script.js] [g_options] ABC_file [f_options] [ABC_file [f_options]]*\n\
Arguments:\n\
  script.js  generation script to load - default: toxhtml.js (XHTML+SVG)\n\
  g_options  global ABC options\n\
  ABC_file   ABC file\n\
  f_options  file options')
		quit()
	}
	abc_cmd("abcjs52", args)







|


|
|
<



42
43
44
45
46
47
48
49
50
51
52
53

54
55
56
	}
	if (typeof abc2svg.abc_init != 'function')
		loadRelativeToScript("toxhtml.js")
	if (!args[0]) {
		printErr('ABC translator with js52 (SpiderMonkey)\
 and abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
  abcjs52 [script.js] [options] ABC_file [[options] ABC_file]* [options]\n\
Arguments:\n\
  script.js  generation script to load - default: toxhtml.js (XHTML+SVG)\n\
  options    ABC options (the last options are moved before the last file)\n\
  ABC_file   ABC file')

		quit()
	}
	abc_cmd("abcjs52", args)
Changes to abcjs60.
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
	}
	if (typeof abc2svg.abc_init != 'function')
		loadRelativeToScript("toxhtml.js")
	if (!args[0]) {
		printErr('ABC translator with js60 (SpiderMonkey)\
 and abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
  abcjs60 [script.js] [g_options] ABC_file [f_options] [ABC_file [f_options]]*\n\
Arguments:\n\
  script.js  generation script to load - default: toxhtml.js (XHTML+SVG)\n\
  g_options  global ABC options\n\
  ABC_file   ABC file\n\
  f_options  file options')
		quit()
	}
	abc_cmd("abcjs60", args)







|


|
|
<



42
43
44
45
46
47
48
49
50
51
52
53

54
55
56
	}
	if (typeof abc2svg.abc_init != 'function')
		loadRelativeToScript("toxhtml.js")
	if (!args[0]) {
		printErr('ABC translator with js60 (SpiderMonkey)\
 and abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
  abcjs60 [script.js] [options] ABC_file [[options] ABC_file]* [options]\n\
Arguments:\n\
  script.js  generation script to load - default: toxhtml.js (XHTML+SVG)\n\
  options    ABC options (the last options are moved before the last file)\n\
  ABC_file   ABC file')

		quit()
	}
	abc_cmd("abcjs60", args)
Changes to abcjsc.
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
		load(args[0])
		args.shift()
	}
	if (!args[0]) {
		print('ABC translator with jsc (webkit2gtk)\
 and abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
  abcjsc [script.js] [g_options] ABC_file [f_options] [ABC_file [f_options]]*\n\
Arguments:\n\
  script.js  script to load - default: toxhtml.js (XHTML+SVG generation)\n\
  g_options  global ABC options\n\
  ABC_file   ABC file\n\
  f_options  file options')
		quit()
	}
	if (typeof(abc2svg.abc_init) != 'function')
		load(progdir + 'toxhtml.js')
	abc_cmd('abcjsc', args)
}








|


|
|
<







73
74
75
76
77
78
79
80
81
82
83
84

85
86
87
88
89
90
91
		load(args[0])
		args.shift()
	}
	if (!args[0]) {
		print('ABC translator with jsc (webkit2gtk)\
 and abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
  abcjsc [script.js] [options] ABC_file [[options] ABC_file]* [options]\n\
Arguments:\n\
  script.js  script to load - default: toxhtml.js (XHTML+SVG generation)\n\
  options    ABC options (the last options are moved before the last file)\n\
  ABC_file   ABC file')

		quit()
	}
	if (typeof(abc2svg.abc_init) != 'function')
		load(progdir + 'toxhtml.js')
	abc_cmd('abcjsc', args)
}

Changes to abcnode.
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
cat <<EOF >> /tmp/toto.js
// main
	var args = process.argv
	if (!args[2]) {
		abc2svg.print('ABC translator with nodeJS\
 and abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
  abcnode [script.js] [g_options] ABC_file [f_options] [ABC_file [f_options]]*\n\
Arguments:\n\
  script.js  generation script to load - default: toxhtml.js (XHTML+SVG)\n\
  g_options  global ABC options\n\
  ABC_file   ABC file\n\
  f_options  file options');
		abc2svg.quit(1)
	}
	args.shift()
	args.shift()
	global.user = user;		// (for modules/page.js)
	abc_cmd("abcnode", args)
EOF







|


|
|
<







63
64
65
66
67
68
69
70
71
72
73
74

75
76
77
78
79
80
81
cat <<EOF >> /tmp/toto.js
// main
	var args = process.argv
	if (!args[2]) {
		abc2svg.print('ABC translator with nodeJS\
 and abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
  abcnode [script.js] [options] ABC_file [[options] ABC_file]* [options]\n\
Arguments:\n\
  script.js  generation script to load - default: toxhtml.js (XHTML+SVG)\n\
  options    ABC options (the last options are moved before the last file)\n\
  ABC_file   ABC file');

		abc2svg.quit(1)
	}
	args.shift()
	args.shift()
	global.user = user;		// (for modules/page.js)
	abc_cmd("abcnode", args)
EOF
Changes to abcqjs.
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
	}
	if (typeof abc2svg.abc_init != 'function')
		std.loadScript(path + "toxhtml.js")
	if (!args[0]) {
		abc2svg.printErr('ABC translator with quickjs\
 and abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
  abcqjs [script.js] [g_options] ABC_file [f_options] [ABC_file [f_options]]*\n\
Arguments:\n\
  script.js  generation script to load - default: toxhtml.js (XHTML+SVG)\n\
  g_options  global ABC options\n\
  ABC_file   ABC file\n\
  f_options  file options')
		abc2svg.quit()
	}
	abc_cmd("abcqjs", args)
EOF
exec qjs --std /tmp/abcqjs.js $0 "$@"

The previous solution with the shebang line as







|


|
|
<







82
83
84
85
86
87
88
89
90
91
92
93

94
95
96
97
98
99
100
	}
	if (typeof abc2svg.abc_init != 'function')
		std.loadScript(path + "toxhtml.js")
	if (!args[0]) {
		abc2svg.printErr('ABC translator with quickjs\
 and abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
  abcqjs [script.js] [options] ABC_file [[options] ABC_file]* [options]\n\
Arguments:\n\
  script.js  generation script to load - default: toxhtml.js (XHTML+SVG)\n\
  options    ABC options (the last options are moved before the last file)\n\
  ABC_file   ABC file'')

		abc2svg.quit()
	}
	abc_cmd("abcqjs", args)
EOF
exec qjs --std /tmp/abcqjs.js $0 "$@"

The previous solution with the shebang line as
Changes to abctopdf.
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#
# Copyright (C) 2019-2020 Jean-François Moine - License GPL3+

if [ $# -eq 0 ]; then
	cat << EOF
ABC to PDF translator using abc2svg
Usage:
  abctopdf [g_options] ABC_file [f_options] [ABC_file [f_options]]* [-o output_file]
Arguments:
  g_options   global ABC options
  ABC_file    ABC file
  f_options   file options
  output_file output file - default is "./abc.pdf"
EOF
	exit 1
fi

# choose a abc2svg batch script with an available JS interpreter
if [ ${0#./} != $0 ]; then







|

|

<







14
15
16
17
18
19
20
21
22
23
24

25
26
27
28
29
30
31
#
# Copyright (C) 2019-2020 Jean-François Moine - License GPL3+

if [ $# -eq 0 ]; then
	cat << EOF
ABC to PDF translator using abc2svg
Usage:
  abctopdf [options] ABC_file [[options] ABC_file] [options] [-o output_file]
Arguments:
  options     ABC options (the last options are moved before the last file)
  ABC_file    ABC file

  output_file output file - default is "./abc.pdf"
EOF
	exit 1
fi

# choose a abc2svg batch script with an available JS interpreter
if [ ${0#./} != $0 ]; then
Changes to abcv8.
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
	if (typeof(abc2svg.abc_init) != 'function')
		load(progdir + 'toxhtml.js')

	if (!args[0]) {
		print('ABC translator with d8 (Google v8 shell)\
 and abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
  abcv8 [script.js] [g_options] ABC_file [f_options] [ABC_file [f_options]]*\n\
Arguments:\n\
  script.js  generation script to load - default: toxhtml.js (XHTML+SVG)\n\
  g_options  global ABC options\n\
  ABC_file   ABC file\n\
  f_options  file options')
		quit()
	}
	abc_cmd('abcv8', args)
"







|


|
|
<




40
41
42
43
44
45
46
47
48
49
50
51

52
53
54
55
	if (typeof(abc2svg.abc_init) != 'function')
		load(progdir + 'toxhtml.js')

	if (!args[0]) {
		print('ABC translator with d8 (Google v8 shell)\
 and abc2svg-' + abc2svg.version + ' ' + abc2svg.vdate + '\n\
Usage:\n\
  abcv8 [script.js] [options] ABC_file [[options] ABC_file]* [options]\n\
Arguments:\n\
  script.js  generation script to load - default: toxhtml.js (XHTML+SVG)\n\
  options    ABC options (the last options are moved before the last file)\n\
  ABC_file   ABC file')

		quit()
	}
	abc_cmd('abcv8', args)
"
Changes to cmdline.js.
88
89
90
91
92
93
94













95
96
97
98
99
100
101
102
103
104
105
106
107




108
109
110
111
112
113
114
115

116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
	} catch (e) {
		abc2svg.abort(e)
	}
} // do_file()

function abc_cmd(cmd, args) {
	var	arg, parm, fn;














	// initialize the backend
	abc = new abc2svg.Abc(user)
	if (typeof global == "object" && !global.abc)
		global.abc = abc
	abc2svg.abc_init(args)

	// load 'default.abc'
	try {
		do_file("default.abc")
	} catch (e) {
	}





	while (1) {
		arg = args.shift()
		if (!arg)
			break
		if (arg[0] == "-") {
			if (arg[1] == "-") {
				parm = args.shift();
				parm = arg.replace('--', 'I:') + " " + parm + "\n"

				abc2svg.modules.load(parm);
				abc.tosvg(cmd, parm)
			}
		} else {
			if (fn) {
				do_file(fn);
				abc.tosvg('cmd', '%%select\n')
			}
			fn = arg
		}
	}
	if (fn)
		do_file(fn);

	abc2svg.abc_end()
}

// nodejs
if (typeof module == 'object' && typeof exports == 'object') {
	exports.user = user;
	exports.abc_cmd = abc_cmd







>
>
>
>
>
>
>
>
>
>
>
>
>













>
>
>
>




|
<
<
|
>
|
|
<

<
|
|
|
<
|
<
<
<
<







88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129


130
131
132
133

134

135
136
137

138




139
140
141
142
143
144
145
	} catch (e) {
		abc2svg.abort(e)
	}
} // do_file()

function abc_cmd(cmd, args) {
	var	arg, parm, fn;

	// put the last options before the last file
	function arg_reorder(a) {
	    var	f,
		i = a.length - 2

		while (i > 2 && a[i].slice(0, 2) == '--')
			i -= 2
		f = a[--i]
		a.splice(i, 1)
		a.push(f)
	} // arg_reorder()


	// initialize the backend
	abc = new abc2svg.Abc(user)
	if (typeof global == "object" && !global.abc)
		global.abc = abc
	abc2svg.abc_init(args)

	// load 'default.abc'
	try {
		do_file("default.abc")
	} catch (e) {
	}

	// put the last options before the last ABC file
	if (args[args.length - 2].slice(0, 2) == '--')
		arg_reorder(args)

	while (1) {
		arg = args.shift()
		if (!arg)
			break
		if (arg[0] == "-" && arg[1] == "-") {


			parm = arg.replace('--', 'I:') + " " +
				args.shift() + "\n"
			abc2svg.modules.load(parm)
			abc.tosvg(cmd, parm)

		} else {

			do_file(arg)
			abc.tosvg('cmd', '%%select\n')
		}

	}




	abc2svg.abc_end()
}

// nodejs
if (typeof module == 'object' && typeof exports == 'object') {
	exports.user = user;
	exports.abc_cmd = abc_cmd