diff --git a/merge_masscode.bas b/merge_masscode.bas index f4f2101..9c89d0b 100644 --- a/merge_masscode.bas +++ b/merge_masscode.bas @@ -4,9 +4,24 @@ $header Function main(argc as int, argv as pchar ptr) dim as JSON_Object Ptr root1, root2 + dim as string filename1, filename2 + + if argc != 3 then + fprint stderr, "Usage: ", Appexename$, " " + end = 1 + else + filename1 = command$(1) + filename2 = command$(2) + end if + + checkFileName(filename1) + checkFileName(filename2) + + if not exist("output") then mkpath("output") + + root1 = loadJson(filename1) + root2 = loadJson(filename2) - root1 = loadJson("db.json") - root2 = loadJson("mac_db.json") if root1 and root2 then addFolderName(root1) addFolderName(root2) @@ -20,6 +35,13 @@ Function main(argc as int, argv as pchar ptr) End Function +Sub checkFileName(filename as string) + if not exist(filename) then + fprint stderr, "ERROR: Could not load ", filename + end = 1 + end if +End Sub + Function loadJson(filename as string) as JSON_Object Ptr dim as JSON_Value Ptr root