initial import

This commit is contained in:
dev
2026-03-16 18:40:55 +08:00
commit d9d1bf8200
29 changed files with 3287 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
export function printResult(data: unknown, raw?: boolean): void {
if (raw) {
console.log(JSON.stringify(data));
} else {
console.log(JSON.stringify(data, null, 2));
}
}
export function exitOnError(err: Error): never {
console.error(`[gmgn-cli] ${err.message}`);
if (process.env.GMGN_DEBUG) {
if ((err as NodeJS.ErrnoException).code) {
console.error(`[gmgn-cli] code: ${(err as NodeJS.ErrnoException).code}`);
}
if ((err as { cause?: unknown }).cause) {
console.error(`[gmgn-cli] cause: ${(err as { cause?: unknown }).cause}`);
}
console.error(err.stack ?? "");
}
process.exit(1);
}