(argv: ArgumentsCamelCase<CommandArgs>)
| 46 | .epilog(buildEpilog({ command, apiDocs: [docNames] })) |
| 47 | |
| 48 | const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => { |
| 49 | const command = await apiCommand(argv) |
| 50 | |
| 51 | const appId = await chooseApp(command, argv.id) |
| 52 | |
| 53 | const tableFieldDefinitions: TableFieldDefinition<GenerateAppOAuthResponse>[] = [ |
| 54 | { path: 'oauthClientDetails.clientName' }, |
| 55 | { path: 'oauthClientDetails.scope' }, |
| 56 | { path: 'oauthClientDetails.redirectUris' }, |
| 57 | 'oauthClientId', |
| 58 | 'oauthClientSecret', |
| 59 | ] |
| 60 | const config: InputAndOutputItemConfig<GenerateAppOAuthResponse> = { |
| 61 | tableFieldDefinitions, |
| 62 | } |
| 63 | const getInputFromUser = async (): Promise<GenerateAppOAuthRequest> => { |
| 64 | const originalOauth = await command.client.apps.getOauth(appId) |
| 65 | const startingRequest: GenerateAppOAuthRequest = { |
| 66 | clientName: originalOauth.clientName, |
| 67 | scope: originalOauth.scope ?? [], |
| 68 | } |
| 69 | const inputDef = objectDef('Generate Request', { |
| 70 | clientName: stringDef('Client Name'), |
| 71 | scope: oauthAppScopeDef, |
| 72 | }, { helpText: itemInputHelpText(docNames) }) |
| 73 | |
| 74 | return updateFromUserInput(command, inputDef, startingRequest, { dryRun: !!argv.dryRun }) |
| 75 | } |
| 76 | |
| 77 | await inputAndOutputItem( |
| 78 | command, |
| 79 | config, |
| 80 | (_, data: GenerateAppOAuthRequest) => command.client.apps.regenerateOauth(appId, data), |
| 81 | inputProcessor(() => true, getInputFromUser), |
| 82 | ) |
| 83 | } |
| 84 | |
| 85 | const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler } |
| 86 | export default cmd |
nothing calls this directly
no test coverage detected