MCPcopy Create free account
hub / github.com/git/git / prompt

Function prompt

git-p4.py:199–215  ·  view source on GitHub ↗

Prompt the user to choose one of the choices. Choices are identified in the prompt_text by square brackets around a single letter option.

(prompt_text)

Source from the content-addressed store, hash-verified

197
198
199def prompt(prompt_text):
200 """Prompt the user to choose one of the choices.
201
202 Choices are identified in the prompt_text by square brackets around a
203 single letter option.
204 """
205 choices = set(m.group(1) for m in re.finditer(r"\[(.)\]", prompt_text))
206 while True:
207 sys.stderr.flush()
208 sys.stdout.write(prompt_text)
209 sys.stdout.flush()
210 response = sys.stdin.readline().strip().lower()
211 if not response:
212 continue
213 response = response[0]
214 if response in choices:
215 return response
216
217
218# We need different encoding/decoding strategies for text data being passed

Callers 2

edit_templateMethod · 0.85
runMethod · 0.85

Calls 2

flushMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected