Implement flatten

This commit is contained in:
contrapunctus 2020-11-28 11:52:00 +05:30
parent c7159a0c6b
commit 729c732695
2 changed files with 20 additions and 10 deletions

View File

@ -126,15 +126,15 @@
6. Create output directory if it doesn't exist!
7. Targets containing other targets.
It would also be useful to compile the part-<instrument>.ly file if I'm editing an <instrument-class>/<instrument>.ly file - useful when working with orchestral files and wanting to put the generated MIDI in qtractor (importing a single track is easier than importing a multi-track MIDI just because you changed music on one track). That's more of an Emacs-side thing, though.
It would also be useful to compile the part-<instrument>.ly file if I'm editing an <instrument-class>/<instrument>.ly file - useful when working with orchestral files and wanting to put the generated MIDI in Qtractor (importing a single track is easier than importing a multi-track MIDI just because you changed music on one track). That's more of an Emacs-side thing, though.
...hell, one could define all kinds of rules - "when I'm working with such-and-such files, compile such-and-such targets."
8. Multiple targets in one command e.g. to compile both the main score and the parts in one command.
** VCS branch integration (2018-11-22T19:43:42+0530)
Check what branch you're on. If it's "master", do nothing. If it's something else, add the name to the output file.
** (2018-11-15T00:44:46+0530)
Currently there's a needless extra layer of arguments for arguments which already exist. Just accept compilation target(s) and pass all of the rest to lilypond(1). Should make code simpler, UI familiar.
** Duplicate layer of CLI options (2018-11-15T00:44:46+0530)
Currently there's a needless extra layer of CLI options for options which already exist. Just accept compilation target(s) and pass all of the rest to lilypond(1). Should make code simpler, UI familiar.
- But the Lilypond CLI is ugly - what's better, "pac=off", or "-dno-point-and-click"? :\
** lack of tab completion sucks (2016-09-29T02:18:01+0530)
I can't even use tab completion from Emacs because the target name has to be "part-<instrument>", not "part-instrument.ly" (so I have to keep deleting the .ly bit)

24
mkly
View File

@ -18,13 +18,19 @@
;; command and args can be strings or symbols
;; symbols will be converted to strings, and spaces will be added
;; `it` is replaced with the input target name
((main.ly lilypond it -o
(string-append dest project-name pac))
;; A target can also be a string, which is assumed to be a
;; regexp which is matched against the input target name
("part-.*\\.ly" lilypond it -o
(string-append dest project-name "-" it pac))
(#t main.ly)))) ;; fallback rule
`((main.ly lilypond it -o
,(string-append dest project-name pac))
;; A target can also be a string, which is assumed to be a
;; regexp which is matched against the input target name
("part-.*\\.ly" lilypond it -o
,(string-append dest project-name "-" it pac))
(#t main.ly)))) ;; fallback rule
(define (flatten seq)
(cond ((null? seq) '())
((not (pair? seq)) (list seq))
(else (append (flatten (car seq))
(flatten (cdr seq))))))
(define *project-name*
(regexp-substitute #f (string-match ".*/" (getcwd)) 'post))
@ -36,6 +42,10 @@
(string-append "^" opt) cli-word))
cli-args))
(define (run-target target-spec)
"Run the command line specified by TARGET-SPEC."
)
(if (< (length (command-line)) 2)
(format #t "~a~%" "Usage: mkly TARGET [ARG=VALUE]*")
(let* ((cli-args (command-line))