Check whether http/https parser can parse the arguments.
(args: List[Union[str, bytes]], env: Environment)
| 10 | |
| 11 | |
| 12 | def is_http_command(args: List[Union[str, bytes]], env: Environment) -> bool: |
| 13 | """Check whether http/https parser can parse the arguments.""" |
| 14 | |
| 15 | from httpie.cli.definition import parser as http_parser |
| 16 | from httpie.manager.cli import COMMANDS |
| 17 | |
| 18 | # If the user already selected a top-level sub-command, never |
| 19 | # show the http/https version. E.g httpie plugins pie.dev/post |
| 20 | if len(args) >= 1 and args[0] in COMMANDS: |
| 21 | return False |
| 22 | |
| 23 | with env.as_silent(): |
| 24 | try: |
| 25 | http_parser.parse_args(env=env, args=args) |
| 26 | except (Exception, SystemExit): |
| 27 | return False |
| 28 | else: |
| 29 | return True |
| 30 | |
| 31 | |
| 32 | def main(args: List[Union[str, bytes]] = sys.argv, env: Environment = Environment()) -> ExitStatus: |
no test coverage detected