package-cleanup/args.ts
2024-01-25 22:33:40 +01:00

36 lines
853 B
TypeScript

import { parseArgs } from "https://deno.land/std@0.213.0/cli/parse_args.ts";
export interface Args {
url: string;
owner: string;
token: string;
}
export function parse(): Args {
const flags = parseArgs(Deno.args, {
string: ["owner", "token", "url"],
boolean: ["help"],
});
if (flags.help) {
printHelp();
Deno.exit(1);
}
const url = flags.url;
const owner = flags.owner;
const token = flags.token;
if (owner == null || token == null || url == null) {
printHelp();
Deno.exit(1);
}
return { owner, token, url };
}
function printHelp() {
console.log("package-cleanup");
console.log("Usage:");
console.log("\t--url\tthe url of the instance (https://git.exmaple.com");
console.log("\t--owner\tthe name of the package owner");
console.log("\t--token\tthe api token");
console.log("\t--help");
}