Spaces:
Sleeping
Sleeping
Download packages/cli/src/utils/output.ts from projectsorg/ever-brain: direct link, hf CLI and curl.
- Browser
- Download file 636 Bytes
-
https://huggingface.co/spaces/projectsorg/ever-brain/resolve/main/packages/cli/src/utils/output.ts
- Command line
-
hf download hf://spaces/projectsorg/ever-brain/packages/cli/src/utils/output.ts
-
curl -L -o output.ts https://huggingface.co/spaces/projectsorg/ever-brain/resolve/main/packages/cli/src/utils/output.ts
636 Bytes
| export interface OutputOptions { | |
| json?: boolean; | |
| } | |
| export function outputResult<T>( | |
| data: T, | |
| options: OutputOptions, | |
| renderHuman: () => void | |
| ): void { | |
| if (options.json) { | |
| console.log(JSON.stringify(data, null, 2)); | |
| } else { | |
| renderHuman(); | |
| } | |
| } | |
| export function outputError( | |
| error: string, | |
| code: string, | |
| options: OutputOptions, | |
| statusCode = 1 | |
| ): never { | |
| if (options.json) { | |
| console.error( | |
| JSON.stringify( | |
| { | |
| error, | |
| code, | |
| }, | |
| null, | |
| 2 | |
| ) | |
| ); | |
| } else { | |
| console.error(`✖ Error [${code}]: ${error}`); | |
| } | |
| process.exit(statusCode); | |
| } | |