From 214a57cdfbf142883012aaec64147331cd6c9612 Mon Sep 17 00:00:00 2001 From: "Jip J. Dekker" Date: Thu, 17 Mar 2016 18:02:15 +0100 Subject: [PATCH] Adds the initial code for the compile command --- cmd/compile.go | 15 ++++++++++++--- compiler/compile.go | 4 +++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cmd/compile.go b/cmd/compile.go index 687b718..1abcfd0 100644 --- a/cmd/compile.go +++ b/cmd/compile.go @@ -15,8 +15,11 @@ package cmd import ( - "fmt" + "path/filepath" + "github.com/jjdekker/ponder/compiler" + "github.com/jjdekker/ponder/helpers" + "github.com/jjdekker/ponder/settings" "github.com/spf13/cobra" ) @@ -29,8 +32,14 @@ lilypond files in accordance to ponder settings file. Files that have already been compiled will be skipped, unless the lilypond file has been edited.`, Run: func(cmd *cobra.Command, args []string) { - // TODO: Work your own magic here - fmt.Println("compile called") + // Find and Unmarshal the settings file + path, err := helpers.FindFileDir(settingsFile) + helpers.Check(err, "unable to find library directory") + opts, err := settings.FromFile(filepath.Join(path, settingsFile)) + helpers.Check(err, "unable to parse settings file") + + // Compile files + compiler.CompileDir(path, opts) }, } diff --git a/compiler/compile.go b/compiler/compile.go index c13dd89..59a1ad6 100644 --- a/compiler/compile.go +++ b/compiler/compile.go @@ -16,6 +16,8 @@ package compiler import "github.com/jjdekker/ponder/settings" -func compileDir(path string, opts *settings.Settings) { +// CompileDir compiles all lilypond files and makes all +// sheet music available in the OutputDir +func CompileDir(path string, opts *settings.Settings) { }