(_program: Command)
| 11 | } |
| 12 | |
| 13 | export function createOpenAction(_program: Command): (path: string | undefined, options: OpenOptions) => Promise<void> { |
| 14 | return async (path, options) => { |
| 15 | try { |
| 16 | debug(`Opening file: ${path}`) |
| 17 | debug(`Options: ${JSON.stringify(options)}`) |
| 18 | await openDeepnoteFile(path, options) |
| 19 | } catch (error) { |
| 20 | // Use InvalidUsage for file resolution errors (user input), Error for runtime failures |
| 21 | const exitCode = error instanceof FileResolutionError ? ExitCode.InvalidUsage : ExitCode.Error |
| 22 | const errorMessage = getErrorMessage(error) |
| 23 | if (options.output === 'json') { |
| 24 | outputJson({ success: false, error: errorMessage }) |
| 25 | } else { |
| 26 | logError(errorMessage) |
| 27 | } |
| 28 | process.exit(exitCode) |
| 29 | } |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | async function openDeepnoteFile(path: string | undefined, options: OpenOptions): Promise<void> { |
| 34 | const { absolutePath } = await resolvePathToDeepnoteFile(path) |
no test coverage detected