(argv: ArgumentsCamelCase<CommandArgs>)
| 52 | .epilog(buildEpilog({ command, apiDocs: ['getModes', 'getMode'] })) |
| 53 | |
| 54 | const handler = async (argv: ArgumentsCamelCase<CommandArgs>): Promise<void> => { |
| 55 | const command = await apiCommand(argv) |
| 56 | |
| 57 | const config: OutputItemOrListConfig<Mode & WithNamedLocation> = { |
| 58 | primaryKeyName: 'id', |
| 59 | sortKeyName: 'label', |
| 60 | listTableFieldDefinitions: tableFieldDefinitions, |
| 61 | tableFieldDefinitions: tableFieldDefinitions, |
| 62 | } |
| 63 | if (argv.verbose) { |
| 64 | config.listTableFieldDefinitions = tableFieldDefinitionsWithLocationName |
| 65 | config.tableFieldDefinitions = tableFieldDefinitionsWithLocationName |
| 66 | } |
| 67 | const modes = await getModesWithLocation(command.client, argv.location) |
| 68 | await outputItemOrList<Mode & WithNamedLocation>( |
| 69 | command, |
| 70 | config, |
| 71 | argv.idOrIndex, |
| 72 | async () => modes, |
| 73 | async id => { |
| 74 | const mode = modes.find(mode => mode.id === id) |
| 75 | if (!mode) { |
| 76 | return fatalError(`could not find mode with id ${id}`) |
| 77 | } |
| 78 | if (argv.verbose) { |
| 79 | return mode |
| 80 | } |
| 81 | // If we aren't using `verbose` flag, get the raw mode again |
| 82 | // so there aren't extra fields in JSON/YAML output |
| 83 | return command.client.modes.get(id, mode.locationId) |
| 84 | }) |
| 85 | } |
| 86 | |
| 87 | const cmd: CommandModule<object, CommandArgs> = { command, describe, builder, handler } |
| 88 | export default cmd |
nothing calls this directly
no test coverage detected