Skip to content

Commit b3ed036

Browse files
committed
added verbose switch
1 parent add38c1 commit b3ed036

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

aws_lambda/aws_lambda.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,16 @@ def deploy(src):
5151
create_function(cfg, path_to_zip_file)
5252

5353

54-
def invoke(src, alt_event=None):
54+
def invoke(src, alt_event=None, verbose=False):
5555
"""Simulates a call to your function.
5656
5757
:param str src:
5858
The path to your Lambda ready project (folder must contain a valid
5959
config.yaml and handler module (e.g.: service.py).
6060
:param str alt_event:
6161
An optional argument to override which event file to use.
62+
:param bool verbose:
63+
Whether to print out verbose details.
6264
"""
6365
# Load and parse the config file.
6466
path_to_config_file = os.path.join(src, 'config.yaml')
@@ -78,15 +80,15 @@ def invoke(src, alt_event=None):
7880

7981
# TODO: look into mocking the ``context`` variable, currently being passed
8082
# as None.
83+
8184
start = time.time()
8285
results = fn(event, None)
8386
end = time.time()
84-
elapsed = end - start
85-
timeout = cfg.get('timeout', 15)
8687

8788
print("{0}".format(results))
88-
print("\nexecution time: {:.8f}s\nfunction execution "
89-
"timeout: {:2}s".format(elapsed, timeout))
89+
if verbose:
90+
print("\nexecution time: {:.8f}s\nfunction execution "
91+
"timeout: {:2}s".format(end - start, cfg.get('timeout', 15)))
9092

9193

9294
def init(src, minimal=False):

scripts/lambda

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,10 @@ def init():
2121

2222

2323
@click.command(help="Run a local test of your function.")
24-
@click.option('--event-file', default=None, help='Alternate event file.',)
25-
def invoke(event_file):
26-
aws_lambda.invoke(CURRENT_DIR, event_file)
24+
@click.option('--event-file', default=None, help='Alternate event file.')
25+
@click.option('--verbose', '-v', is_flag=True)
26+
def invoke(event_file, verbose):
27+
aws_lambda.invoke(CURRENT_DIR, event_file, verbose)
2728

2829

2930
@click.command(help="Register and deploy your code to lambda.")

0 commit comments

Comments
 (0)