Adds setting and flag to keep generated LaTeX book template
This commit is contained in:
parent
677c167df4
commit
d38ef88c9c
@ -19,6 +19,8 @@ import (
|
|||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var keepTemplate bool
|
||||||
|
|
||||||
// bookCmd represents the book command
|
// bookCmd represents the book command
|
||||||
var bookCmd = &cobra.Command{
|
var bookCmd = &cobra.Command{
|
||||||
Use: "book",
|
Use: "book",
|
||||||
@ -26,10 +28,13 @@ var bookCmd = &cobra.Command{
|
|||||||
Long: ``,
|
Long: ``,
|
||||||
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
|
||||||
compiler.MakeBook(path, opts)
|
compiler.MakeBook(path, opts)
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
bookCmd.Flags().BoolVarP(&keepTemplate, "keep-template",
|
||||||
|
"k", false, "Leave the LaTeX source for the book in the output directory")
|
||||||
RootCmd.AddCommand(bookCmd)
|
RootCmd.AddCommand(bookCmd)
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,9 @@ func MakeBook(path string, opts *settings.Settings) {
|
|||||||
"error": err,
|
"error": err,
|
||||||
}).Error("failed to clean songbook latex files")
|
}).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")
|
helpers.Check(err, "could not remove songbook latex template")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +36,7 @@ type Settings struct {
|
|||||||
BookTitleTempl string // Override for the partial book template creating the title page
|
BookTitleTempl string // Override for the partial book template creating the title page
|
||||||
BookCategoryTempl string // Override for the partial book template creating category pages
|
BookCategoryTempl string // Override for the partial book template creating category pages
|
||||||
BookScoreTempl string // Override for the partial book template placing scores
|
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
|
// FromFile reads a settings file in json format and returns the Settings struct
|
||||||
|
Reference in New Issue
Block a user