Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
core.py43 linesDownload Raw Back to manager
1import argparse2from typing import Optional3 4from httpie.context import Environment5from httpie.status import ExitStatus6from httpie.manager.cli import missing_subcommand, parser7from httpie.manager.tasks import CLI_TASKS8 9MSG_COMMAND_CONFUSION = '''\10This command is only for managing HTTPie plugins.11To send a request, please use the http/https commands:12 13  $ http {args}14 15  $ https {args}16'''17 18# noinspection PyStringFormat19MSG_NAKED_INVOCATION = f'''\20{missing_subcommand()}21 22{MSG_COMMAND_CONFUSION}23'''.rstrip("\n").format(args='POST pie.dev/post hello=world')24 25 26def dispatch_cli_task(env: Environment, action: Optional[str], args: argparse.Namespace) -> ExitStatus:27    if action is None:28        parser.error(missing_subcommand('cli'))29 30    return CLI_TASKS[action](env, args)31 32 33def program(args: argparse.Namespace, env: Environment) -> ExitStatus:34    if args.action is None:35        parser.error(MSG_NAKED_INVOCATION)36 37    if args.action == 'plugins':38        return dispatch_cli_task(env, args.action, args)39    elif args.action == 'cli':40        return dispatch_cli_task(env, args.cli_action, args)41 42    return ExitStatus.SUCCESS43 
codekingpro/portable-devtools · Team Ai