mirror of
https://github.com/httpie/cli.git
synced 2024-11-28 08:38:44 +02:00
c157948531
* Add `httpie cli plugins` in favor of the new cli namespace. * Separate each task to individual modules. * Move httpie.manager.plugins to httpie.manager.tasks.plugins Co-authored-by: Jakub Roztocil <jakub@roztocil.co>
28 lines
701 B
Python
28 lines
701 B
Python
import argparse
|
|
import json
|
|
|
|
from httpie.cli.definition import options
|
|
from httpie.cli.options import to_data
|
|
from httpie.output.writer import write_raw_data
|
|
from httpie.status import ExitStatus
|
|
from httpie.context import Environment
|
|
|
|
|
|
FORMAT_TO_CONTENT_TYPE = {
|
|
'json': 'application/json'
|
|
}
|
|
|
|
|
|
def cli_export_args(env: Environment, args: argparse.Namespace) -> ExitStatus:
|
|
if args.format == 'json':
|
|
data = json.dumps(to_data(options))
|
|
else:
|
|
raise NotImplementedError(f'Unexpected format value: {args.format}')
|
|
|
|
write_raw_data(
|
|
env,
|
|
data,
|
|
stream_kwargs={'mime_overwrite': FORMAT_TO_CONTENT_TYPE[args.format]},
|
|
)
|
|
return ExitStatus.SUCCESS
|