MCPcopy Index your code
hub / github.com/google/python-fire / AddSeparator

Method AddSeparator

fire/trace.py:136–158  ·  view source on GitHub ↗

Marks that the most recent element of the trace used a separator. A separator is an argument you can pass to a Fire CLI to separate args left of the separator from args right of the separator. Here's an example to demonstrate the separator. Let's say you have a function that takes

(self)

Source from the content-addressed store, hash-verified

134 self.elements.append(element)
135
136 def AddSeparator(self):
137 """Marks that the most recent element of the trace used a separator.
138
139 A separator is an argument you can pass to a Fire CLI to separate args left
140 of the separator from args right of the separator.
141
142 Here's an example to demonstrate the separator. Let's say you have a
143 function that takes a variable number of args, and you want to call that
144 function, and then upper case the result. Here's how to do it:
145
146 # in Python
147 def display(arg1, arg2='!'):
148 return arg1 + arg2
149
150 # from Bash (the default separator is the hyphen -)
151 display hello # hello!
152 display hello upper # helloupper
153 display hello - upper # HELLO!
154
155 Note how the separator caused the display function to be called with the
156 default value for arg2.
157 """
158 self.elements[-1].AddSeparator()
159
160 def _Quote(self, arg):
161 if arg.startswith('--') and '=' in arg:

Calls

no outgoing calls