| 149 | |
| 150 | # noinspection PyMethodOverriding |
| 151 | def parse_args( |
| 152 | self, |
| 153 | env: Environment, |
| 154 | args=None, |
| 155 | namespace=None |
| 156 | ) -> argparse.Namespace: |
| 157 | self.env = env |
| 158 | self.env.args = namespace = namespace or argparse.Namespace() |
| 159 | self.args, no_options = super().parse_known_args(args, namespace) |
| 160 | if self.args.debug: |
| 161 | self.args.traceback = True |
| 162 | self.has_stdin_data = ( |
| 163 | self.env.stdin |
| 164 | and not self.args.ignore_stdin |
| 165 | and not self.env.stdin_isatty |
| 166 | ) |
| 167 | self.has_input_data = self.has_stdin_data or self.args.raw is not None |
| 168 | # Arguments processing and environment setup. |
| 169 | self._apply_no_options(no_options) |
| 170 | self._process_request_type() |
| 171 | self._process_download_options() |
| 172 | self._setup_standard_streams() |
| 173 | self._process_output_options() |
| 174 | self._process_pretty_options() |
| 175 | self._process_format_options() |
| 176 | self._guess_method() |
| 177 | self._parse_items() |
| 178 | self._process_url() |
| 179 | self._process_auth() |
| 180 | self._process_ssl_cert() |
| 181 | |
| 182 | if self.args.raw is not None: |
| 183 | self._body_from_input(self.args.raw) |
| 184 | elif self.has_stdin_data: |
| 185 | self._body_from_file(self.env.stdin) |
| 186 | |
| 187 | if self.args.compress: |
| 188 | # TODO: allow --compress with --chunked / --multipart |
| 189 | if self.args.chunked: |
| 190 | self.error('cannot combine --compress and --chunked') |
| 191 | if self.args.multipart: |
| 192 | self.error('cannot combine --compress and --multipart') |
| 193 | |
| 194 | return self.args |
| 195 | |
| 196 | def _process_request_type(self): |
| 197 | request_type = self.args.request_type |