mirror of
https://github.com/beilunyang/moemail.git
synced 2026-05-07 06:13:07 +08:00
feat(cli): add output formatting helpers
This commit is contained in:
27
packages/cli/src/output.ts
Normal file
27
packages/cli/src/output.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
/**
|
||||
* Print JSON to stdout (for --json mode).
|
||||
*/
|
||||
export function printJson(data: unknown): void {
|
||||
console.log(JSON.stringify(data));
|
||||
}
|
||||
|
||||
/**
|
||||
* Print human-readable text to stdout.
|
||||
*/
|
||||
export function printText(text: string): void {
|
||||
console.log(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Log to stderr (progress, errors — never pollutes stdout).
|
||||
*/
|
||||
export function log(message: string): void {
|
||||
console.error(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert epoch ms timestamp to ISO 8601 string.
|
||||
*/
|
||||
export function msToIso(ms: number): string {
|
||||
return new Date(ms).toISOString();
|
||||
}
|
||||
Reference in New Issue
Block a user