feat: add arg outpath

This commit is contained in:
monoid 2022-04-20 22:24:47 +09:00
parent 38f82409bd
commit d2010834b7

View File

@ -47,21 +47,33 @@ async function readContent(path?: string):Promise<string>{
}
if(import.meta.main){
const args = argParse(Deno.args);
const url = new URL(import.meta.url)
url.pathname = normalize(pathJoin(url.pathname,"..","template"));
const path = fromFileUrl(url);
console.log(path);
Eta.configure({views: path});
let args = argParse(Deno.args);
if(typeof args.path !== "string"){
console.log("Please provide a path to the json file.");
Deno.exit(1);
}
const c = await readContent(args.path);
const issues = JSON.parse(c) as Issue[];
let print: string = "";
if(args.overall){
const c = await Eta.renderFile("overall.md.eta",{
print = await Eta.renderFile("overall.md.eta",{
issues: issues.sort((a,b)=>a.number-b.number)
});
console.log(c);
}) as string;
}
else{
printContent(issues);
}
if(args.outpath){
Deno.writeTextFileSync(args.outpath,print);
}
else{
console.log(print);
}
}