Archived
1
0

Adds setting and flag to keep generated LaTeX book template

This commit is contained in:
Jip J. Dekker 2016-04-19 11:55:27 +02:00
parent 677c167df4
commit d38ef88c9c
3 changed files with 9 additions and 1 deletions

View File

@ -19,6 +19,8 @@ import (
"github.com/spf13/cobra"
)
var keepTemplate bool
// bookCmd represents the book command
var bookCmd = &cobra.Command{
Use: "book",
@ -26,10 +28,13 @@ var bookCmd = &cobra.Command{
Long: ``,
Run: func(cmd *cobra.Command, args []string) {
path, opts := getSettings()
opts.KeepBookTemplate = opts.KeepBookTemplate || keepTemplate
compiler.MakeBook(path, opts)
},
}
func init() {
bookCmd.Flags().BoolVarP(&keepTemplate, "keep-template",
"k", false, "Leave the LaTeX source for the book in the output directory")
RootCmd.AddCommand(bookCmd)
}

View File

@ -70,7 +70,9 @@ func MakeBook(path string, opts *settings.Settings) {
"error": err,
}).Error("failed to clean songbook latex files")
}
err = os.Remove(texPath)
if !opts.KeepBookTemplate {
err = os.Remove(texPath)
}
helpers.Check(err, "could not remove songbook latex template")
}

View File

@ -36,6 +36,7 @@ type Settings struct {
BookTitleTempl string // Override for the partial book template creating the title page
BookCategoryTempl string // Override for the partial book template creating category pages
BookScoreTempl string // Override for the partial book template placing scores
KeepBookTemplate bool // Leave the LaTeX source for the book in the output directory
}
// FromFile reads a settings file in json format and returns the Settings struct