MCPcopy
hub / github.com/httpie/cli / _apply_no_options

Method _apply_no_options

httpie/cli/argparser.py:357–380  ·  view source on GitHub ↗

For every `--no-OPTION` in `no_options`, set `args.OPTION` to its default value. This allows for un-setting of options, e.g., specified in config.

(self, no_options)

Source from the content-addressed store, hash-verified

355 self.args.auth = ExplicitNullAuth()
356
357 def _apply_no_options(self, no_options):
358 """For every `--no-OPTION` in `no_options`, set `args.OPTION` to
359 its default value. This allows for un-setting of options, e.g.,
360 specified in config.
361
362 """
363 invalid = []
364
365 for option in no_options:
366 if not option.startswith('--no-'):
367 invalid.append(option)
368 continue
369
370 # --no-option => --option
371 inverted = '--' + option[5:]
372 for action in self._actions:
373 if inverted in action.option_strings:
374 setattr(self.args, action.dest, action.default)
375 break
376 else:
377 invalid.append(option)
378
379 if invalid:
380 self.error(f'unrecognized arguments: {" ".join(invalid)}')
381
382 def _body_from_file(self, fd):
383 """Read the data from a file-like object.

Callers 1

parse_argsMethod · 0.95

Calls 1

errorMethod · 0.95

Tested by

no test coverage detected