aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--pkg/datamaps/config.go4
-rw-r--r--pkg/datamaps/writer.go9
-rw-r--r--pkg/datamaps/writer_test.go2
3 files changed, 10 insertions, 5 deletions
diff --git a/pkg/datamaps/config.go b/pkg/datamaps/config.go
index f370ba4..b21da5c 100644
--- a/pkg/datamaps/config.go
+++ b/pkg/datamaps/config.go
@@ -203,6 +203,8 @@ func processOptions(opts *Options, allArgs []string) {
opts.Command = "setup"
case "server":
opts.Command = "server"
+ case "createmaster":
+ opts.Command = "createmaster"
default:
log.Fatal("No relevant command provided.")
}
@@ -224,6 +226,8 @@ func processOptions(opts *Options, allArgs []string) {
opts.DMOverwrite = true
case "--initial":
opts.DMInitial = true
+ case "--masteroutputdir":
+ opts.MasterOutPutPath = nextString(restArgs, &i, "master output directory required")
}
}
}
diff --git a/pkg/datamaps/writer.go b/pkg/datamaps/writer.go
index 8e721d0..defb656 100644
--- a/pkg/datamaps/writer.go
+++ b/pkg/datamaps/writer.go
@@ -12,15 +12,17 @@ import (
_ "github.com/mattn/go-sqlite3"
)
-func ExportMaster(opts *Options) error {
+// CreateMaster creates a master spreadsheet for a specific return given,
+// based on a datamap name - both of which already need to be in the database,
+// along with the data associated with the return. The datamap and return data
+// must already have been imported.
+func CreateMaster(opts *Options) error {
wb := xlsx.NewFile()
sh, err := wb.AddSheet("Master Data")
if err != nil {
return fmt.Errorf("cannot add 'Master Data' sheet to new XLSX file: %v", err)
}
- // SQLITE CODE
-
db, err := sql.Open("sqlite3", opts.DBPath)
if err != nil {
return fmt.Errorf("cannot open database %v", err)
@@ -103,7 +105,6 @@ func ExportMaster(opts *Options) error {
}
for masterRow := 0; masterRow < len(datamapKeys); masterRow++ {
- log.Printf("Writing to masterRow which is %d", masterRow)
r, err := sh.AddRowAtIndex(masterRow)
if err != nil {
return fmt.Errorf("cannot create row %d in output spreadsheet: %v", masterRow, err)
diff --git a/pkg/datamaps/writer_test.go b/pkg/datamaps/writer_test.go
index 319544c..92af664 100644
--- a/pkg/datamaps/writer_test.go
+++ b/pkg/datamaps/writer_test.go
@@ -40,7 +40,7 @@ func TestWriteMaster(t *testing.T) {
t.Fatalf("cannot read test XLSX files needed before exporting to master - %v", err)
}
- if err := ExportMaster(&opts); err != nil {
+ if err := CreateMaster(&opts); err != nil {
t.Error(err)
}
}