github.com/SAP/cloud-mta-build-tool@v1.2.27/cmd/merge.go (about) 1 package commands 2 3 import ( 4 "os" 5 6 "github.com/spf13/cobra" 7 8 "github.com/SAP/cloud-mta-build-tool/internal/artifacts" 9 ) 10 11 var mergeCmdSrc string 12 var mergeCmdTrg string 13 var mergeCmdExtensions []string 14 var mergeCmdName string 15 16 // Merge mta.yaml with mta extension files and write the result. 17 var mergeCmd = &cobra.Command{ 18 Use: "merge", 19 Short: `Merges the "mta.yaml" file with the MTA extension descriptors`, 20 Long: `Merges the "mta.yaml" file with the MTA extension descriptors`, 21 Args: cobra.NoArgs, 22 RunE: func(cmd *cobra.Command, args []string) error { 23 err := artifacts.ExecuteMerge(mergeCmdSrc, mergeCmdTrg, mergeCmdExtensions, mergeCmdName, os.Getwd) 24 return err 25 }, 26 Hidden: true, 27 SilenceUsage: true, 28 } 29 30 func init() { 31 // set flag of merge command 32 mergeCmd.Flags().StringVarP(&mergeCmdSrc, "source", "s", "", 33 "The path to the MTA project; the current path is set as default") 34 mergeCmd.Flags().StringVarP(&mergeCmdTrg, "target", "t", 35 "", "The path to the folder in which the merged file is generated") 36 mergeCmd.Flags().StringSliceVarP(&mergeCmdExtensions, "extensions", "e", nil, 37 "The MTA extension descriptors") 38 mergeCmd.Flags().StringVarP(&mergeCmdName, "target-file-name", "n", "", 39 `(required) The result file name`) 40 }