Archived
1
0

Adds setting and flag to enable Lilypond's point and click

This commit is contained in:
Jip J. Dekker 2016-06-16 00:16:34 +02:00
parent 971fcd2fd8
commit 99a8e7042a
4 changed files with 11 additions and 0 deletions

View File

@ -20,6 +20,7 @@ import (
) )
var keepTemplate bool var keepTemplate bool
var enablePointAndClick bool
// bookCmd represents the book command // bookCmd represents the book command
var bookCmd = &cobra.Command{ var bookCmd = &cobra.Command{
@ -29,6 +30,7 @@ var bookCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
path, opts := getSettings() path, opts := getSettings()
opts.KeepBookTemplate = opts.KeepBookTemplate || keepTemplate opts.KeepBookTemplate = opts.KeepBookTemplate || keepTemplate
opts.EnablePointAndClick = opts.EnablePointAndClick || enablePointAndClick
compiler.MakeBook(path, opts) compiler.MakeBook(path, opts)
}, },
} }
@ -36,5 +38,7 @@ var bookCmd = &cobra.Command{
func init() { func init() {
bookCmd.Flags().BoolVarP(&keepTemplate, "keep-template", bookCmd.Flags().BoolVarP(&keepTemplate, "keep-template",
"k", false, "Leave the LaTeX source for the book in the output directory") "k", false, "Leave the LaTeX source for the book in the output directory")
bookCmd.Flags().BoolVarP(&enablePointAndClick, "clickable",
"c", false, "Enable Lilypond's Point and Click functionality")
RootCmd.AddCommand(bookCmd) RootCmd.AddCommand(bookCmd)
} }

View File

@ -29,10 +29,13 @@ Files that have already been compiled will be skipped,
unless the lilypond file has been edited.`, unless the lilypond file has been edited.`,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
path, opts := getSettings() path, opts := getSettings()
opts.EnablePointAndClick = opts.EnablePointAndClick || enablePointAndClick
compiler.CompileDir(path, opts) compiler.CompileDir(path, opts)
}, },
} }
func init() { func init() {
compileCmd.Flags().BoolVarP(&enablePointAndClick, "clickable",
"c", false, "Enable Lilypond's Point and Click functionality")
RootCmd.AddCommand(compileCmd) RootCmd.AddCommand(compileCmd)
} }

View File

@ -37,6 +37,9 @@ func PrepareLilypond(opts *settings.Settings) {
} }
lilypondArgs = append(lilypondArgs, "--loglevel=ERROR") lilypondArgs = append(lilypondArgs, "--loglevel=ERROR")
lilypondArgs = append(lilypondArgs, "--pdf") lilypondArgs = append(lilypondArgs, "--pdf")
if !opts.EnablePointAndClick {
lilypondArgs = append(lilypondArgs, "-dno-point-and-click")
}
} }
// Lilypond runs the lilypond compiler on the given path // Lilypond runs the lilypond compiler on the given path

View File

@ -40,6 +40,7 @@ type Settings struct {
KeepBookTemplate bool // Leave the LaTeX source for the book in the output directory KeepBookTemplate bool // Leave the LaTeX source for the book in the output directory
FlatOutputDir bool // Keep all output file in a flat output directory FlatOutputDir bool // Keep all output file in a flat output directory
DefaultCategories []string // Categories included in the book by default DefaultCategories []string // Categories included in the book by default
EnablePointAndClick bool // Enable Lilypond's Point and Click functionality
} }
// FromFile reads a settings file in json format and returns the Settings struct // FromFile reads a settings file in json format and returns the Settings struct