-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Expand file tree
/
Copy pathcommand.py
More file actions
63 lines (54 loc) · 2.62 KB
/
Copy pathcommand.py
File metadata and controls
63 lines (54 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
"""
Invoke Command Class.
"""
from click import Context, style
from samcli.cli.core.command import CoreCommand
from samcli.cli.row_modifiers import RowDefinition, ShowcaseRowModifier
from samcli.commands.local.start_api.core.formatters import InvokeStartAPICommandHelpTextFormatter
from samcli.commands.local.start_api.core.options import OPTIONS_INFO
class InvokeAPICommand(CoreCommand):
class CustomFormatterContext(Context):
formatter_class = InvokeStartAPICommandHelpTextFormatter
context_class = CustomFormatterContext
@staticmethod
def format_examples(ctx: Context, formatter: InvokeStartAPICommandHelpTextFormatter):
with formatter.indented_section(name="Examples", extra_indents=1):
with formatter.indented_section(name="Setup", extra_indents=1):
formatter.write_rd(
[
RowDefinition(
text="\n",
),
RowDefinition(
name="Start the local lambda with Amazon API Gateway endpoint",
),
RowDefinition(
name=style(f"$ {ctx.command_path}"),
extra_row_modifiers=[ShowcaseRowModifier()],
),
]
)
with formatter.indented_section(name="Invoke local Lambda endpoint", extra_indents=1):
formatter.write_rd(
[
RowDefinition(
text="\n",
),
RowDefinition(
name="Invoke Lambda function locally using curl",
),
RowDefinition(
name=style("$ curl http://127.0.0.1:3000/hello"),
extra_row_modifiers=[ShowcaseRowModifier()],
),
]
)
def format_options(self, ctx: Context, formatter: InvokeStartAPICommandHelpTextFormatter) -> None: # type:ignore
# NOTE(sriram-mv): `ignore` is put in place here for mypy even though it is the correct behavior,
# as the `formatter_class` can be set in subclass of Command. If ignore is not set,
# mypy raises argument needs to be HelpFormatter as super class defines it.
self.format_description(formatter)
InvokeAPICommand.format_examples(ctx, formatter)
CoreCommand._format_options(
ctx=ctx, params=self.get_params(ctx), formatter=formatter, formatting_options=OPTIONS_INFO
)