Skip to content

Commit

Permalink
Removed the management command.
Browse files Browse the repository at this point in the history
It means that:

    httpie session list
    httpie session edit
    ...

are gone.

It has never been part of a stable release, and since it wasn't
a very useful feature, it's beeing removed now to avoid feature creep.
  • Loading branch information
jkbrzt committed Feb 22, 2013
1 parent 3043f24 commit 5cc5b13
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 207 deletions.
28 changes: 2 additions & 26 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -886,15 +886,14 @@ Session data are stored in JSON files in the directory
**Warning:** All session data, including credentials, cookie data,
and custom headers are stored in plain text.
Another way to create or update a session is to use the `management tool`_
and then edit the raw JSON manually:
Session files can also be created or edited with a text editor.
.. code-block:: bash
$ httpie session edit example.org user1
See also `Management Tool`_ and `Config`_.
See also `Config`_.
======
Expand Down Expand Up @@ -938,28 +937,6 @@ The config directory location can be changed by setting the
``HTTPIE_CONFIG_DIR`` environment variable.
===============
Management Tool
===============
The main executable HTTPie comes with is ``http``, which is used for making
HTTP requests. The ``httpie`` command, on the other hand, is a utility for
managing your configuration. The currently supported actions are:
``httpie session list [hostname]``:
List all existing sessions, or a host's sessions only.
``httpie session edit hostname session-name``:
Create and/or edit a session file in ``$EDITOR``.
``httpie session show hostname session-name``:
Print a session data to the console.
``httpie session delete hostname [session-name]``
Delete all host's sessions or a specific one by name.
=========
Scripting
=========
Expand Down Expand Up @@ -1103,7 +1080,6 @@ Changelog
* `0.4.0-alpha`_
* Python 3.3 compatibility.
* Requests v1.0.4 compatibility.
* Added ``httpie`` management command.
* Added support for credentials in URL.
* Added ``--no-option`` for every ``--option`` to be config-friendly.
* Mutually exclusive arguments can be specified multiple times. The
Expand Down
10 changes: 6 additions & 4 deletions httpie/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
from . import __doc__
from . import __version__
from .compat import is_windows
from .sessions import DEFAULT_SESSIONS_DIR
from .manage import session_name_validator
from .sessions import DEFAULT_SESSIONS_DIR, Session
from .output import AVAILABLE_STYLES, DEFAULT_STYLE
from .input import (Parser, AuthCredentialsArgType, KeyValueArgType,
SEP_PROXY, SEP_CREDENTIALS, SEP_GROUP_ITEMS,
OUT_REQ_HEAD, OUT_REQ_BODY, OUT_RESP_HEAD,
OUT_RESP_BODY, OUTPUT_OPTIONS,
PRETTY_MAP, PRETTY_STDOUT_TTY_ONLY)
PRETTY_MAP, PRETTY_STDOUT_TTY_ONLY, RegexValidator)


def _(text):
Expand Down Expand Up @@ -224,7 +223,10 @@ def _(text):
.add_mutually_exclusive_group(required=False)

sessions.add_argument(
'--session', metavar='SESSION_NAME', type=session_name_validator,
'--session', metavar='SESSION_NAME', type=RegexValidator(
Session.VALID_NAME_PATTERN,
'Session name contains invalid characters.'
),
help=_('''
Create, or reuse and update a session.
Within a session, custom headers, auth credential, as well as any
Expand Down
109 changes: 0 additions & 109 deletions httpie/manage.py

This file was deleted.

68 changes: 0 additions & 68 deletions httpie/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@
"""
import re
import os
import sys
import glob
import errno
import codecs
import shutil
import subprocess

import requests
from requests.cookies import RequestsCookieJar, create_cookie
from requests.auth import HTTPBasicAuth, HTTPDigestAuth

from .compat import urlsplit
from .config import BaseConfigDict, DEFAULT_CONFIG_DIR
from .output import PygmentsProcessor


SESSIONS_DIR_NAME = 'sessions'
Expand Down Expand Up @@ -181,67 +177,3 @@ def auth(self, cred):
'username': cred.username,
'password': cred.password,
}


##################################################################
# Session management commands
##################################################################


def command_session_list(hostname=None):
"""Print a list of all sessions or only
the ones from `args.host`, if provided.
"""
if hostname:
for session in Host(hostname):
print(session.verbose_name)
else:
for host in Host.all():
for session in host:
print(session.verbose_name)


def command_session_show(hostname, session_name):
"""Print JSON data for a session."""
session = Session(Host(hostname), session_name)
path = session.path
if not os.path.exists(path):
sys.stderr.write('Session does not exist: %s\n'
% session.verbose_name)
sys.exit(1)

with codecs.open(path, encoding='utf8') as f:
print(session.verbose_name + ':\n')
proc = PygmentsProcessor()
print(proc.process_body(f.read(), 'application/json', 'json'))
print('')


def command_session_delete(hostname, session_name=None):
"""Delete a session by host and name, or delete all the
host's session if name not provided.
"""
host = Host(hostname)
if not session_name:
host.delete()
session = Session(host, session_name)
session.delete()


def command_session_edit(hostname, session_name):
"""Open a session file in EDITOR."""
editor = os.environ.get('EDITOR', None)
if not editor:
sys.stderr.write(
'You need to configure the environment variable EDITOR.\n')
sys.exit(1)

session = Session(Host(hostname), session_name)
if session.is_new:
session.save()

command = editor.split()
command.append(session.path)
subprocess.call(command)

0 comments on commit 5cc5b13

Please sign in to comment.