(argv: ArgumentsCamelCase<CommandArgs>)
| 39 | .epilog(buildEpilog({ command })) |
| 40 | |
| 41 | const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => { |
| 42 | const command = await apiOrganizationCommand(argv) |
| 43 | |
| 44 | const currentOrganizationId = command.cliConfig.stringConfigValue('organization') |
| 45 | const getOrganization = async (id: string): Promise<OrganizationResponse | undefined> => { |
| 46 | try { |
| 47 | return await command.client.organizations.get(id) |
| 48 | } catch (error) { |
| 49 | if (error.response?.status === 403) { |
| 50 | return undefined |
| 51 | } |
| 52 | throw error |
| 53 | } |
| 54 | } |
| 55 | const currentOrganization = currentOrganizationId |
| 56 | ? await getOrganization(currentOrganizationId) |
| 57 | : (await command.client.organizations.list()).find(org => org.isDefaultUserOrg) |
| 58 | |
| 59 | if (currentOrganization) { |
| 60 | await formatAndWriteItem(command, { tableFieldDefinitions }, currentOrganization) |
| 61 | } else { |
| 62 | if (currentOrganizationId) { |
| 63 | console.error(`Organization '${currentOrganizationId}' not found`) |
| 64 | } else { |
| 65 | console.error('Could not find an active organization.') |
| 66 | } |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler } |
| 71 | export default cmd |
nothing calls this directly
no test coverage detected