import { parse } from './cli-parameters' ; import { OsnapError , ErrorCode } from './errors' ; import { usage } from './cli-usage' ; import { saveToFile as iosSave } from './ios' ; import { saveToFile as androidSave } from './android' ; import { copyToClipboard } from './copy-to-clipboard' ; /**
 * Runs the CLI and returns the exit code we should use.
 */ export async function run ( ) { try { const parameters = parse ( ) ; if ( parameters . platform === 'ios' ) { await iosSave ( parameters ) ; } else if ( parameters . platform === 'android' ) { await androidSave ( parameters ) ; } if ( parameters . useClipboard ) { await copyToClipboard ( parameters . filename ) ; } return 0 ; } catch ( err ) { if ( ( err as OsnapError ) . code === ErrorCode . MissingPlatform ) { console . log ( usage ) ; return 0 ; } else { console . error ( err . message ) ; return 1 ; } } }