initial cli api, some movement on tool selection
This commit is contained in:
32
main.ts
32
main.ts
@@ -1,30 +1,4 @@
|
||||
import { PDFDocument } from "pdf-lib";
|
||||
import { loadPdfForm } from "./saveLoadPdf.ts";
|
||||
import { PdfToolsCli } from "./cli/index.ts";
|
||||
|
||||
let [pdfPath, csPath] = Deno.args;
|
||||
|
||||
while (!pdfPath || !pdfPath.endsWith('.pdf')) pdfPath = prompt("Please provide path to PDF file:") || "";
|
||||
while (!csPath || !csPath.endsWith('.cs')) csPath = prompt("Please provide path to CS class file:") || "";
|
||||
|
||||
const form = await loadPdfForm(pdfPath);
|
||||
|
||||
const fields = form.getFields();
|
||||
const csFiles = await Promise.all(csPath.split(",").map(c => Deno.readTextFile(c.trim())));
|
||||
|
||||
const fieldNames: string[] = fields.map(f => f.getName())
|
||||
.filter(f => {
|
||||
const rx = new RegExp(`(?<!//\s?)case ?"${f.replace(/\[\d\]/, '\\[\\?\\]')}"`)
|
||||
return !csFiles.some(c => rx.test(c))
|
||||
})
|
||||
.filter(f => !f.toLowerCase().includes("signature"));
|
||||
|
||||
if (fieldNames.length) {
|
||||
console.log("%cThe following field names are not present in the CS code", "color: red")
|
||||
console.log(fieldNames)
|
||||
alert("Your princess is in another castle...")
|
||||
} else {
|
||||
console.log("%cAll form fields present", 'color: lime')
|
||||
alert("Ok!")
|
||||
}
|
||||
|
||||
/additionalAdviser.personalInfo.npn\[\?\]/
|
||||
const app = new PdfToolsCli();
|
||||
app.run();
|
||||
|
Reference in New Issue
Block a user