@@ -3,21 +3,31 @@ package com.getstrm.pace.dbt
3
3
import com.fasterxml.jackson.databind.ObjectMapper
4
4
import java.io.File
5
5
import java.io.FileNotFoundException
6
+ import java.nio.file.Paths
6
7
import kotlin.system.exitProcess
7
8
8
- fun main () {
9
+ fun main (args : Array <String >) {
10
+ val basePath = if (args.isEmpty()) {
11
+ Paths .get(" " ).toAbsolutePath().toString()
12
+ } else if (args.size == 1 ) {
13
+ args[0 ]
14
+ } else {
15
+ println (" Either provide 0 arguments or an absolute path to the dbt project directory." )
16
+ exitProcess(1 )
17
+ }
18
+
9
19
System .setProperty(" org.jooq.no-logo" , " true" )
10
20
System .setProperty(" org.jooq.no-tips" , " true" )
11
21
12
22
// Note! Working dir when running this must be the root of the desired dbt project!
13
23
try {
14
24
val manifestJson =
15
- File (" target/manifest.json" ).readText().let { ObjectMapper ().readTree(it) }
25
+ File (" $basePath / target/manifest.json" ).readText().let { ObjectMapper ().readTree(it) }
16
26
17
27
val dataPolicies = ManifestParser .createDataPolicies(manifestJson)
18
28
dataPolicies.forEach { (policy, sourceModel, violations) ->
19
29
if (violations.isEmpty()) {
20
- ModelWriter (policy, sourceModel).write()
30
+ ModelWriter (policy, sourceModel, basePath ).write()
21
31
} else {
22
32
println (
23
33
" Skipping policy for source model ${sourceModel.originalFilePath} due to violations: $violations "
0 commit comments