feat: getIssue.ts print json
This commit is contained in:
parent
b890a4073a
commit
41933dbe98
@ -1,5 +1,6 @@
|
||||
#! /usr/bin/env deno run --allow-net --allow-env
|
||||
import {Issue} from "./githubType.ts";
|
||||
import {parse} from "https://deno.land/std@0.135.0/flags/mod.ts";
|
||||
|
||||
/**
|
||||
* get issue from github
|
||||
@ -25,13 +26,17 @@ export async function getIssues(repo: string, token: string): Promise<Issue[]> {
|
||||
|
||||
|
||||
if (import.meta.main) {
|
||||
const arg = Deno.args.length > 0 ? Deno.args[0] : undefined;
|
||||
const token = arg ?? Deno.env.get("GITHUB_TOKEN");
|
||||
const args = parse(Deno.args);
|
||||
const token = args.token ?? Deno.env.get("GITHUB_TOKEN");
|
||||
if(typeof token !== "string"){
|
||||
console.error("invalid type: token must be string");
|
||||
Deno.exit(1);
|
||||
}
|
||||
if(!token) {
|
||||
console.error("GITHUB_TOKEN is not set");
|
||||
Deno.exit(1);
|
||||
}
|
||||
const issues = await getIssues("vi117/scrap-yard", token);
|
||||
issues.sort((a, b) => a.number - b.number);
|
||||
console.log(issues.map(i => `# (${i.number}) ${i.title}\n${i.body}`).join("\n\n"));
|
||||
console.log(JSON.stringify(issues,undefined,2));
|
||||
}
|
Loading…
Reference in New Issue
Block a user