import { contextFinder, helpMessage } from "./context_finder.ts"import { fileExists } from "./helpers.ts";
async function runFromCommandLine () { if (import.meta.main !== true) { return false } const args = Deno.args if (args[0] === '--help') { console.info(helpMessage) Deno.exit(1) }
if (args.length < 3) { console.error('Invalid arguments. See --help') Deno.exit(1) }
const fileToRead = args[0] const fileToWriteTo = args[1] const contexts = (args.slice(2)).filter(arg => arg.indexOf('--') == -1)
const fileToReadExists = await fileExists(fileToRead) if (!fileToReadExists) { console.error('File to read does not exist.') Deno.exit(1) }
contextFinder(contexts, fileToRead, fileToWriteTo)}
await runFromCommandLine()
export { contextFinder }