MCPcopy Index your code
hub / github.com/pyinvoke/invoke / complete_flag

Method complete_flag

invoke/parser/parser.py:359–379  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

357 debug("Context inverse_flags: {!r}".format(self.context.inverse_flags))
358
359 def complete_flag(self) -> None:
360 if self.flag:
361 msg = "Completing current flag {} before moving on"
362 debug(msg.format(self.flag))
363 # Barf if we needed a value and didn't get one
364 if (
365 self.flag
366 and self.flag.takes_value
367 and self.flag.raw_value is None
368 and not self.flag.optional
369 ):
370 err = "Flag {!r} needed value and was not given one!"
371 self.error(err.format(self.flag))
372 # Handle optional-value flags; at this point they were not given an
373 # explicit value, but they were seen, ergo they should get treated like
374 # bools.
375 if self.flag and self.flag.raw_value is None and self.flag.optional:
376 msg = "Saw optional flag {!r} go by w/ no value; setting to True"
377 debug(msg.format(self.flag.name))
378 # Skip casting so the bool gets preserved
379 self.flag.set_value(True, cast=False)
380
381 def check_ambiguity(self, value: Any) -> bool:
382 """

Callers 1

switch_to_flagMethod · 0.95

Calls 2

errorMethod · 0.95
set_valueMethod · 0.80

Tested by

no test coverage detected