Apply defaults to output options, or validate the provided ones. The default output options are stdout-type-sensitive.
(self)
| 490 | self.args.headers['Content-Type'] = content_type |
| 491 | |
| 492 | def _process_output_options(self): |
| 493 | """Apply defaults to output options, or validate the provided ones. |
| 494 | |
| 495 | The default output options are stdout-type-sensitive. |
| 496 | |
| 497 | """ |
| 498 | |
| 499 | def check_options(value, option): |
| 500 | unknown = set(value) - OUTPUT_OPTIONS |
| 501 | if unknown: |
| 502 | self.error(f'Unknown output options: {option}={",".join(unknown)}') |
| 503 | |
| 504 | if self.args.verbose: |
| 505 | self.args.all = True |
| 506 | |
| 507 | if self.args.output_options is None: |
| 508 | if self.args.verbose >= 2: |
| 509 | self.args.output_options = ''.join(OUTPUT_OPTIONS) |
| 510 | elif self.args.verbose == 1: |
| 511 | self.args.output_options = ''.join(BASE_OUTPUT_OPTIONS) |
| 512 | elif self.args.offline: |
| 513 | self.args.output_options = OUTPUT_OPTIONS_DEFAULT_OFFLINE |
| 514 | elif not self.env.stdout_isatty: |
| 515 | self.args.output_options = OUTPUT_OPTIONS_DEFAULT_STDOUT_REDIRECTED |
| 516 | else: |
| 517 | self.args.output_options = OUTPUT_OPTIONS_DEFAULT |
| 518 | |
| 519 | if self.args.output_options_history is None: |
| 520 | self.args.output_options_history = self.args.output_options |
| 521 | |
| 522 | check_options(self.args.output_options, '--print') |
| 523 | check_options(self.args.output_options_history, '--history-print') |
| 524 | |
| 525 | if self.args.download and OUT_RESP_BODY in self.args.output_options: |
| 526 | # Response body is always downloaded with --download and it goes |
| 527 | # through a different routine, so we remove it. |
| 528 | self.args.output_options = str( |
| 529 | set(self.args.output_options) - set(OUT_RESP_BODY)) |
| 530 | |
| 531 | def _process_pretty_options(self): |
| 532 | if self.args.prettify == PRETTY_STDOUT_TTY_ONLY: |