MCPcopy Index your code
hub / github.com/aws/aws-sam-cli / format_options

Method format_options

samcli/cli/command.py:115–142  ·  view source on GitHub ↗
(self, ctx: click.Context, formatter: RootCommandHelpTextFormatter)

Source from the content-addressed store, hash-verified

113 return commands
114
115 def format_options(self, ctx: click.Context, formatter: RootCommandHelpTextFormatter): # type: ignore
116 # NOTE(sriram-mv): `ignore` is put in place here for mypy even though it is the correct behavior,
117 # as the `formatter_class` can be set in subclass of Command. If ignore is not set,
118 # mypy raises argument needs to be HelpFormatter as super class defines it.
119 # NOTE(sriram-mv): Re-order options so that they come after the commands.
120 self.format_commands(ctx, formatter)
121
122 opts = []
123 for param in self.get_params(ctx):
124 row = param.get_help_record(ctx)
125 if row is not None:
126 term, help_text = row
127 opts.append(RowDefinition(name=term, text=help_text))
128
129 if opts:
130 with formatter.indented_section(name="Options", extra_indents=1):
131 formatter.write_rd(opts)
132
133 with formatter.indented_section(name="Examples", extra_indents=1):
134 with formatter.indented_section(name="Get Started", extra_indents=1):
135 formatter.write_text_rows(
136 [
137 RowDefinition(
138 name=click.style(f"$ {ctx.command_path} init"),
139 extra_row_modifiers=[ShowcaseRowModifier()],
140 ),
141 ],
142 )
143
144 def format_commands(self, ctx: click.Context, formatter: RootCommandHelpTextFormatter): # type: ignore
145 # NOTE(sriram-mv): `ignore` is put in place here for mypy even though it is the correct behavior,

Calls 7

format_commandsMethod · 0.95
RowDefinitionClass · 0.90
ShowcaseRowModifierClass · 0.90
get_help_recordMethod · 0.45
indented_sectionMethod · 0.45
write_rdMethod · 0.45
write_text_rowsMethod · 0.45