Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions awscli/argprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ def _is_complex_shape(model):
return True


def register_param_shorthand_parser(event_emitter):
event_emitter.register(
'process-cli-arg',
ParamShorthandParser(),
)


class ParamShorthand:
def _uses_old_list_case(self, command_name, operation_name, argument_name):
"""
Expand Down
7 changes: 7 additions & 0 deletions awscli/clidriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,13 @@ def _set_user_agent_for_session(session):
add_session_id_component_to_user_agent_extra(session)


def register_no_pager_handler(event_emitter):
event_emitter.register(
'session-initialized',
no_pager_handler,
)


def no_pager_handler(session, parsed_args, **kwargs):
if parsed_args.no_cli_pager:
config_store = session.get_component('config_store')
Expand Down
13 changes: 13 additions & 0 deletions awscli/customizations/addexamples.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@
LOG = logging.getLogger(__name__)


def register_docs_add_examples(event_emitter):
# The following will get fired for every option we are
# documenting. It will attempt to add an example_fn on to
# the parameter object if the parameter supports shorthand
# syntax. The documentation event handlers will then use
# the examplefn to generate the sample shorthand syntax
# in the docs. Registering here should ensure that this
# handler gets called first, but it still feels a bit brittle.
# event_handlers.register('doc-option-example.*.*.*',
# param_shorthand.add_example_fn)
event_emitter.register('doc-examples.*.*', add_examples)


def add_examples(help_command, **kwargs):
doc_path = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'examples'
Expand Down
7 changes: 7 additions & 0 deletions awscli/customizations/binaryformat.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
from awscli.shorthand import ModelVisitor


def register_init_binary_formatter(event_emitter):
event_emitter.register(
'session-initialized',
add_binary_formatter,
)


def add_binary_formatter(session, parsed_args, **kwargs):
binary_format = parsed_args.cli_binary_format
if binary_format is None:
Expand Down
8 changes: 4 additions & 4 deletions awscli/customizations/codedeploy/codedeploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
from awscli.customizations.codedeploy.uninstall import Uninstall


def initialize(cli):
"""
The entry point for CodeDeploy high level commands.
"""
def register_rename_codedeploy(cli):
cli.register('building-command-table.main', change_name)


def register_codedeploy(cli):
cli.register('building-command-table.deploy', inject_commands)
cli.register(
'building-argument-table.deploy.get-application-revision',
Expand Down
7 changes: 7 additions & 0 deletions awscli/customizations/ec2/decryptpassword.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@
password data sent from EC2 will be decrypted before display.</p>"""


def register_ec2_add_priv_launch_key(event_emitter, **kwargs):
event_emitter.register(
'building-argument-table.ec2.get-password-data',
ec2_add_priv_launch_key,
)


def ec2_add_priv_launch_key(
argument_table, operation_model, session, **kwargs
):
Expand Down
14 changes: 14 additions & 0 deletions awscli/customizations/iot.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,20 @@
from awscli.customizations.arguments import QueryOutFileArgument


def register_iot_create_keys_from_csr(event_emitter):
event_emitter.register(
'building-argument-table.iot.create-certificate-from-csr',
register_create_keys_from_csr_arguments,
)


def register_iot_create_keys_and_cert_args(event_emitter):
event_emitter.register(
'building-argument-table.iot.create-keys-and-certificate',
register_create_keys_and_cert_arguments,
)


def register_create_keys_and_cert_arguments(session, argument_table, **kwargs):
"""Add outfile save arguments to create-keys-and-certificate

Expand Down
21 changes: 6 additions & 15 deletions awscli/customizations/s3/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,23 +28,14 @@
)


def awscli_initialize(cli):
"""
This function is require to use the plugin. It calls the functions
required to add all necessary commands and parameters to the CLI.
This function is necessary to install the plugin using a configuration
file
"""
cli.register("building-command-table.main", add_s3)
cli.register('building-command-table.s3_sync', register_sync_strategies)
def register_s3_main(event_handlers):
event_handlers.register('building-command-table.main', add_s3)


def s3_plugin_initialize(event_handlers):
"""
This is a wrapper to make the plugin built-in to the cli as opposed
to specifying it in the configuration file.
"""
awscli_initialize(event_handlers)
def register_s3_sync_strategies(event_handlers):
event_handlers.register(
'building-command-table.s3_sync', register_sync_strategies
)


def add_s3(command_table, session, **kwargs):
Expand Down
7 changes: 7 additions & 0 deletions awscli/customizations/streamingoutputarg.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
from awscli.arguments import BaseCLIArgument


def register_streaming_output_arg(event_emitter):
event_emitter.register(
'building-argument-table.*',
add_streaming_output_arg,
)


def add_streaming_output_arg(
argument_table, operation_model, session, **kwargs
):
Expand Down
77 changes: 34 additions & 43 deletions awscli/handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
"""

from awscli.alias import register_alias_commands
from awscli.argprocess import ParamShorthandParser
from awscli.clidriver import no_pager_handler
from awscli.argprocess import register_param_shorthand_parser
from awscli.clidriver import register_no_pager_handler
from awscli.customizations import datapipeline
from awscli.customizations.addexamples import add_examples
from awscli.customizations.addexamples import register_docs_add_examples
from awscli.customizations.argrename import register_arg_renames
from awscli.customizations.assumerole import register_assume_role_provider
from awscli.customizations.awslambda import register_lambda_create_function
from awscli.customizations.binaryformat import add_binary_formatter
from awscli.customizations.binaryformat import register_init_binary_formatter
from awscli.customizations.cliinput import register_cli_input_args
from awscli.customizations.cloudformation import (
initialize as cloudformation_init,
Expand All @@ -38,7 +38,10 @@
from awscli.customizations.codeartifact import register_codeartifact_commands
from awscli.customizations.codecommit import initialize as codecommit_init
from awscli.customizations.codedeploy.codedeploy import (
initialize as codedeploy_init,
register_codedeploy,
)
from awscli.customizations.codedeploy.codedeploy import (
register_rename_codedeploy as codedeploy_init,
)
from awscli.customizations.configservice.getstatus import register_get_status
from awscli.customizations.configservice.putconfigurationrecorder import (
Expand All @@ -58,7 +61,9 @@
)
from awscli.customizations.ec2.addcount import register_count_events
from awscli.customizations.ec2.bundleinstance import register_bundleinstance
from awscli.customizations.ec2.decryptpassword import ec2_add_priv_launch_key
from awscli.customizations.ec2.decryptpassword import (
register_ec2_add_priv_launch_key,
)
from awscli.customizations.ec2.paginate import register_ec2_page_size_injector
from awscli.customizations.ec2.protocolarg import register_protocol_args
from awscli.customizations.ec2.runinstances import register_runinstances
Expand Down Expand Up @@ -88,8 +93,8 @@
)
from awscli.customizations.iamvirtmfa import IAMVMFAWrapper
from awscli.customizations.iot import (
register_create_keys_and_cert_arguments,
register_create_keys_from_csr_arguments,
register_iot_create_keys_and_cert_args,
register_iot_create_keys_from_csr,
)
from awscli.customizations.iot_data import register_custom_endpoint_note
from awscli.customizations.kinesis import (
Expand All @@ -113,7 +118,10 @@
)
from awscli.customizations.removals import register_removals
from awscli.customizations.route53 import register_create_hosted_zone_doc_fix
from awscli.customizations.s3.s3 import s3_plugin_initialize
from awscli.customizations.s3.s3 import (
register_s3_main,
register_s3_sync_strategies,
)
from awscli.customizations.s3errormsg import register_s3_error_msg
from awscli.customizations.s3events import (
register_document_expires_string,
Expand All @@ -125,50 +133,38 @@
from awscli.customizations.sessendemail import register_ses_send_email
from awscli.customizations.sessionmanager import register_ssm_session
from awscli.customizations.sso import register_sso_commands
from awscli.customizations.streamingoutputarg import add_streaming_output_arg
from awscli.customizations.streamingoutputarg import (
register_streaming_output_arg,
)
from awscli.customizations.timestampformat import register_timestamp_format
from awscli.customizations.toplevelbool import register_bool_params
from awscli.customizations.translate import (
register_translate_import_terminology,
)
from awscli.customizations.waiters import register_add_waiters
from awscli.customizations.wizard.commands import register_wizard_commands
from awscli.paramfile import register_uri_param_handler
from awscli.paramfile import register_init_uri_param_handler


def awscli_initialize(event_handlers):
event_handlers.register('session-initialized', register_uri_param_handler)
event_handlers.register('session-initialized', add_binary_formatter)
event_handlers.register('session-initialized', no_pager_handler)
param_shorthand = ParamShorthandParser()
event_handlers.register('process-cli-arg', param_shorthand)
# The s3 error mesage needs to registered before the
register_init_uri_param_handler(event_handlers)
register_init_binary_formatter(event_handlers)
register_no_pager_handler(event_handlers)
register_param_shorthand_parser(event_handlers)
# The s3 error message needs to registered before the
# generic error handler.
register_s3_error_msg(event_handlers)
# # The following will get fired for every option we are
# # documenting. It will attempt to add an example_fn on to
# # the parameter object if the parameter supports shorthand
# # syntax. The documentation event handlers will then use
# # the examplefn to generate the sample shorthand syntax
# # in the docs. Registering here should ensure that this
# # handler gets called first but it still feels a bit brittle.
# event_handlers.register('doc-option-example.*.*.*',
# param_shorthand.add_example_fn)
event_handlers.register('doc-examples.*.*', add_examples)
register_docs_add_examples(event_handlers)
register_cli_input_args(event_handlers)
event_handlers.register(
'building-argument-table.*', add_streaming_output_arg
)
register_streaming_output_arg(event_handlers)
register_count_events(event_handlers)
event_handlers.register(
'building-argument-table.ec2.get-password-data',
ec2_add_priv_launch_key,
)
register_ec2_add_priv_launch_key(event_handlers)
register_parse_global_args(event_handlers)
register_pagination(event_handlers)
register_secgroup(event_handlers)
register_bundleinstance(event_handlers)
s3_plugin_initialize(event_handlers)
register_s3_main(event_handlers)
register_s3_sync_strategies(event_handlers)
register_ddb(event_handlers)
register_runinstances(event_handlers)
register_removals(event_handlers)
Expand Down Expand Up @@ -199,6 +195,7 @@ def awscli_initialize(event_handlers):
register_assume_role_provider(event_handlers)
register_add_waiters(event_handlers)
codedeploy_init(event_handlers)
register_codedeploy(event_handlers)
register_subscribe(event_handlers)
register_get_status(event_handlers)
register_rename_config(event_handlers)
Expand All @@ -210,14 +207,8 @@ def awscli_initialize(event_handlers):
register_codeartifact_commands(event_handlers)
codecommit_init(event_handlers)
register_custom_endpoint_note(event_handlers)
event_handlers.register(
'building-argument-table.iot.create-keys-and-certificate',
register_create_keys_and_cert_arguments,
)
event_handlers.register(
'building-argument-table.iot.create-certificate-from-csr',
register_create_keys_from_csr_arguments,
)
register_iot_create_keys_and_cert_args(event_handlers)
register_iot_create_keys_from_csr(event_handlers)
register_cloudfront(event_handlers)
register_gamelift_commands(event_handlers)
register_ec2_page_size_injector(event_handlers)
Expand Down
Loading
Loading