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

Function is_http_command

httpie/manager/__main__.py:12–29  ·  view source on GitHub ↗

Check whether http/https parser can parse the arguments.

(args: List[Union[str, bytes]], env: Environment)

Source from the content-addressed store, hash-verified

10
11
12def 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
32def main(args: List[Union[str, bytes]] = sys.argv, env: Environment = Environment()) -> ExitStatus:

Callers 1

mainFunction · 0.85

Calls 2

as_silentMethod · 0.80
parse_argsMethod · 0.45

Tested by

no test coverage detected