Run HTTPie manager command with the given args/kwargs, and capture stderr/out and exit status.
(
*args,
**kwargs
)
| 288 | |
| 289 | |
| 290 | def httpie( |
| 291 | *args, |
| 292 | **kwargs |
| 293 | ) -> StrCLIResponse: |
| 294 | """ |
| 295 | Run HTTPie manager command with the given |
| 296 | args/kwargs, and capture stderr/out and exit |
| 297 | status. |
| 298 | """ |
| 299 | |
| 300 | env = kwargs.setdefault('env', MockEnvironment()) |
| 301 | cli_args = ['httpie'] |
| 302 | if not kwargs.pop('no_debug', False): |
| 303 | cli_args.append('--debug') |
| 304 | cli_args += normalize_args(args) |
| 305 | exit_status = manager.main( |
| 306 | args=cli_args, |
| 307 | **kwargs |
| 308 | ) |
| 309 | |
| 310 | env.stdout.seek(0) |
| 311 | env.stderr.seek(0) |
| 312 | try: |
| 313 | response = BaseCLIResponse.from_raw_data(env.stdout.read()) |
| 314 | response.stderr = env.stderr.read() |
| 315 | response.exit_status = exit_status |
| 316 | response.args = cli_args |
| 317 | finally: |
| 318 | env.stdout.truncate(0) |
| 319 | env.stderr.truncate(0) |
| 320 | env.stdout.seek(0) |
| 321 | env.stderr.seek(0) |
| 322 | |
| 323 | return response |
| 324 | |
| 325 | |
| 326 | def http( |