| 164 | return self._global_args_parser |
| 165 | |
| 166 | def on_building_command_table( |
| 167 | self, command_table, event_name, command_object, session, **kwargs |
| 168 | ): |
| 169 | if ( |
| 170 | not isinstance(command_object, CLICommand) |
| 171 | and event_name == 'building-command-table.main' |
| 172 | ): |
| 173 | self._global_cmd_driver = command_object |
| 174 | return |
| 175 | # We have to transform the event name to figure out what the |
| 176 | # hierarchy of commands actually is. Normally the hierarchical |
| 177 | # events are separated by dots: |
| 178 | # |
| 179 | # some-event.cloudformation.wait.stack-exists |
| 180 | # |
| 181 | # But specifically for the `building-command-table` event, this |
| 182 | # was purposefully avoided to workaround a specific bug. |
| 183 | # As a result the actual event name for |
| 184 | # |
| 185 | # "aws cloudformation wait stack-exists" would be: |
| 186 | # |
| 187 | # building-command-table.cloudformation_wait_stack-exists |
| 188 | # |
| 189 | # See https://github.com/aws/aws-cli/pull/5714 for more details. |
| 190 | key_name = tuple(event_name.split('.', 1)[1].split('_')) |
| 191 | aliases_for_cmd = self._alias_loader.get_aliases(command=key_name) |
| 192 | if not aliases_for_cmd: |
| 193 | return |
| 194 | for alias_name, alias_value in aliases_for_cmd.items(): |
| 195 | if self._is_external_alias(alias_value): |
| 196 | self._inject_external_alias( |
| 197 | alias_name, alias_value, command_table |
| 198 | ) |
| 199 | else: |
| 200 | proxied_sub_command = command_table.get(alias_name) |
| 201 | command_table[alias_name] = InternalAliasSubCommand( |
| 202 | alias_name, |
| 203 | alias_value, |
| 204 | command_object, |
| 205 | self._retrieve_global_args_parser(), |
| 206 | session=session, |
| 207 | proxied_sub_command=proxied_sub_command, |
| 208 | ) |
| 209 | |
| 210 | |
| 211 | class BaseAliasCommand(CLICommand): |