MCPcopy
hub / github.com/pallets/click / _match_long_opt

Method _match_long_opt

src/click/parser.py:363–388  ·  view source on GitHub ↗
(
        self, opt: str, explicit_value: str | None, state: _ParsingState
    )

Source from the content-addressed store, hash-verified

361 # not a very interesting subset!
362
363 def _match_long_opt(
364 self, opt: str, explicit_value: str | None, state: _ParsingState
365 ) -> None:
366 if opt not in self._long_opt:
367 raise NoSuchOption(opt, possibilities=self._long_opt, ctx=self.ctx)
368
369 option = self._long_opt[opt]
370 if option.takes_value:
371 # At this point it's safe to modify rargs by injecting the
372 # explicit value, because no exception is raised in this
373 # branch. This means that the inserted value will be fully
374 # consumed.
375 if explicit_value is not None:
376 state.rargs.insert(0, explicit_value)
377
378 value = self._get_value_from_state(opt, option, state)
379
380 elif explicit_value is not None:
381 raise BadOptionUsage(
382 opt, _("Option {name!r} does not take a value.").format(name=opt)
383 )
384
385 else:
386 value = UNSET
387
388 option.process(value, state)
389
390 def _match_short_opt(self, arg: str, state: _ParsingState) -> None:
391 stop = False

Callers 1

_process_optsMethod · 0.95

Calls 4

_get_value_from_stateMethod · 0.95
NoSuchOptionClass · 0.85
BadOptionUsageClass · 0.85
processMethod · 0.45

Tested by

no test coverage detected