7 * Add @nodes, split at sections?
16 program_name = 'lys-to-tely'
18 include_snippets = '@lysnippets'
19 fragment_options = 'printfilename,texidoc'
22 sys.stdout.write (r"""Usage: %(program_name)s [OPTIONS]... LY-FILE...
23 Construct tely doc from LY-FILEs.
26 -h, --help print this help
27 -f, --fragment-options=OPTIONS use OPTIONS as lilypond-book fragment
29 -o, --output=NAME write tely doc to NAME
30 -t, --title=TITLE set tely doc title TITLE
31 --template=TEMPLATE use TEMPLATE as Texinfo template file,
32 instead of standard template; TEMPLATE should contain a command
33 '%(include_snippets)s' to tell where to insert LY-FILEs. When this
34 option is used, NAME and TITLE are ignored.
38 (options, files) = getopt.getopt (sys.argv[1:], 'f:hn:t:',
39 ['fragment-options=', 'help', 'name=', 'title=', 'template='])
43 template = '''\input texinfo
44 @setfilename %%(name)s.info
47 @documentencoding utf-8
52 @finalout @c we do not want black boxes.
56 @author Han-Wen Nienhuys and Jan Nieuwenhuizen
65 ''' % include_snippets
70 if o == '-h' or o == '--help':
72 elif o == '-n' or o == '--name':
74 elif o == '-t' or o == '--title':
76 elif o == '-f' or o == '--fragment-options':
78 elif o == '--template':
79 template = open (a, 'r').read ()
81 raise Exception ('unknown option: ' + o)
92 @lilypondfile[%s]{%s}""" % (n, fragment_options, n)
96 dir = os.path.dirname (name) or "."
97 # don't strip .tely extension, input/lsr uses .itely
98 name = os.path.basename (name)
99 template = template % vars ()
102 s = "\n".join (map (name2line, files))
103 s = template.replace (include_snippets, s, 1)
104 f = "%s/%s" % (dir, name)
105 sys.stderr.write ("%s: writing %s..." % (program_name, f))
109 sys.stderr.write ('\n')
111 # not Unix philosophy, but hey, at least we notice when
112 # we don't distribute any .ly files.
113 sys.stderr.write ("No files specified. Doing nothing")