Files
ts-scripts/single-scripts/get-secret.ts

32 lines
739 B
TypeScript
Executable File

#!/usr/bin/env -S deno run -A
import {args, exit, getSecretValue,} from "https://script.hatter.ink/@66/deno-commons-mod.ts";
import {parseArgs} from "jsr:@std/cli/parse-args";
const flags = parseArgs(args(), {
boolean: ["help", "refresh"],
string: ["id"],
});
if (flags.help) {
console.log(
"export RUN_ENV=ALIBABA_CLOUD or `echo ALIBABA_CLOUD > ~/.config/envs/RUN_ENV` runs on Alibaba Cloud ECS or light server",
);
console.log(
"get-secret.ts --id ID",
);
exit(0);
}
if (flags.id) {
console.log(
await getSecretValue(flags.id, {
tryRefresh: flags.refresh,
}),
);
exit(0);
} else {
console.error("get-secret.ts --id is required");
exit(1);
}