Varying output from single file
Hoping for the ability to output variations on a score from a single .ly file.
For example the vocalist only needs a "lead sheet", but for myself I may also want a piano staff.
There are command line options which could perhaps set an environment variable, but I'm not sure if the .ly file itself provides the ability to check for some dynamic state.
Imagining something like:
I expect this is doable and will be obvious once becoming comfortable with the extension language, Scheme.
Conditional content can be done quite easily:
You can also pass arguments by CLI by using the -e argument, which allows evaluating some code. So you can e.g. call lilypond as
lilypond -e "(define-public my_flag #t)" ...
and then access my_flag (if it is defined). Note that this code is evaluated in a guile module named lily-user, so to access the value you need to load that module:
#(use-modules (guile-user))
and then check for
(and (defined? 'ly_animate_CLI_FLAG) ly_animate_CLI_FLAG)
(defaults to #f) or
(if (defined? 'ly_animate_CLI_FLAG) ly_animate_CLI_FLAG default-value)
That being said, Lilypond itself allows for creating multiple output files from one input file, using \book { ... }. So it might be viable for you to generate multiple pdfs from one file rather than having to pass in flags for specific files. Using \book you can also use \bookOutputSuffix "some-label" to specify a suffix to the pdf name, so your input file would generate a ...-leadsheet.pdf and a ...-piano.pdf and whatever, or \bookOutputName "name" to give a completely different name to each book.
Note that this still can use conditional code by doing a scheme function:
or by using tags: