A small application to manage Lilypond music repositories
1// Copyright © 2016 Jip J. Dekker <jip@dekker.li>
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15package cmd
16
17import (
18 log "github.com/Sirupsen/logrus"
19
20 "github.com/jjdekker/ponder/helpers"
21 "github.com/jjdekker/ponder/settings"
22 "github.com/spf13/cobra"
23)
24
25// addCmd represents the add command
26var addCmd = &cobra.Command{
27 Use: "add [file]+",
28 Short: "Add pdf file to a book",
29 Long: `Add creates a json file with all options regarding a sheet music file
30in PDF format. The information saved in the json file will be used when
31compiling the songbook.`,
32 Run: func(cmd *cobra.Command, args []string) {
33 var (
34 path string
35 err error
36 )
37 dir, _ := getSettings()
38 for i := range args {
39 path, err = helpers.CleanPath(args[i])
40 helpers.Check(err, "Unable to create valid path")
41 log.WithFields(log.Fields{"path": path}).Info("creating score json file")
42 settings.CreateScore(path, dir)
43 }
44 },
45}
46
47func init() {
48 RootCmd.AddCommand(addCmd)
49}