1
0
mirror of https://github.com/httpie/cli.git synced 2025-01-10 00:28:12 +02:00
httpie-cli/httpie/manage.py

65 lines
1.7 KiB
Python
Raw Normal View History

"""
Provides the `httpie' management command.
Note that the main `http' command points to `httpie.__main__.main()`.
"""
import argparse
2012-12-01 20:16:00 +03:00
from argparse import OPTIONAL
from . import __version__
2012-12-01 20:16:00 +03:00
from .sessions import (command_session_list,
command_session_edit,
command_session_show,
command_session_delete)
parser = argparse.ArgumentParser(
description='The HTTPie management command.',
version=__version__
)
subparsers = parser.add_subparsers()
2012-12-01 20:16:00 +03:00
#################################################################
# Session commands
#################################################################
session = subparsers.add_parser('session',
help='manipulate and inspect sessions').add_subparsers()
# List
list_ = session.add_parser('list', help='list sessions')
list_.set_defaults(command=command_session_list)
list_.add_argument('host', nargs=OPTIONAL)
# Show
show = session.add_parser('show', help='show a session')
show.set_defaults(command=command_session_show)
show.add_argument('host')
show.add_argument('name')
# Edit
edit = session.add_parser(
'edit', help='edit a session in $EDITOR')
edit.set_defaults(command=command_session_edit)
edit.add_argument('host')
edit.add_argument('name')
# Delete
delete = session.add_parser('delete', help='delete a session')
delete.set_defaults(command=command_session_delete)
delete.add_argument('host')
delete.add_argument('name', nargs=OPTIONAL,
help='The name of the session to be deleted.'
' If not specified, all host sessions are deleted.')
def main():
args = parser.parse_args()
2012-08-19 05:58:14 +03:00
args.command(args)
if __name__ == '__main__':
main()