MCPcopy
hub / github.com/google/python-fire / _SynopsisSection

Function _SynopsisSection

fire/helptext.py:118–139  ·  view source on GitHub ↗

The "Synopsis" section of the help string.

(component, actions_grouped_by_kind, spec, metadata,
                     trace=None)

Source from the content-addressed store, hash-verified

116
117
118def _SynopsisSection(component, actions_grouped_by_kind, spec, metadata,
119 trace=None) -> tuple[str, str]:
120 """The "Synopsis" section of the help string."""
121 current_command = _GetCurrentCommand(trace=trace, include_separators=True)
122
123 possible_actions = _GetPossibleActions(actions_grouped_by_kind)
124
125 continuations = []
126 if possible_actions:
127 continuations.append(_GetPossibleActionsString(possible_actions))
128 if callable(component):
129 callable_continuation = _GetArgsAndFlagsString(spec, metadata)
130 if callable_continuation:
131 continuations.append(callable_continuation)
132 elif trace:
133 # This continuation might be blank if no args are needed.
134 # In this case, show a separator.
135 continuations.append(trace.separator)
136 continuation = ' | '.join(continuations)
137
138 text = f'{current_command} {continuation}'
139 return ('SYNOPSIS', text)
140
141
142def _DescriptionSection(component, info) -> tuple[str, str] | None:

Callers 1

HelpTextFunction · 0.85

Calls 4

_GetCurrentCommandFunction · 0.85
_GetPossibleActionsFunction · 0.85
_GetArgsAndFlagsStringFunction · 0.85

Tested by

no test coverage detected