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

Method GetCommand

fire/trace.py:166–190  ·  view source on GitHub ↗

Returns the command representing the trace up to this point. Args: include_separators: Whether or not to include separators in the command. Returns: A string representing a Fire CLI command that would produce this trace.

(self, include_separators=True)

Source from the content-addressed store, hash-verified

164 return shlex.quote(arg)
165
166 def GetCommand(self, include_separators=True):
167 """Returns the command representing the trace up to this point.
168
169 Args:
170 include_separators: Whether or not to include separators in the command.
171
172 Returns:
173 A string representing a Fire CLI command that would produce this trace.
174 """
175 args = []
176 if self.name:
177 args.append(self.name)
178
179 for element in self.elements:
180 if element.HasError():
181 continue
182 if element.args:
183 args.extend(element.args)
184 if element.HasSeparator() and include_separators:
185 args.append(self.separator)
186
187 if self.NeedsSeparator() and include_separators:
188 args.append(self.separator)
189
190 return ' '.join(self._Quote(arg) for arg in args)
191
192 def NeedsSeparator(self):
193 """Returns whether a separator should be added to the command.

Callers 7

testGetCommandMethod · 0.95
_IsHelpShortcutFunction · 0.80
_DisplayErrorFunction · 0.80
_GetCurrentCommandFunction · 0.80
UsageTextFunction · 0.80

Calls 4

NeedsSeparatorMethod · 0.95
_QuoteMethod · 0.95
HasSeparatorMethod · 0.80
HasErrorMethod · 0.45

Tested by 3

testGetCommandMethod · 0.76