1
0
mirror of https://github.com/httpie/cli.git synced 2024-11-24 08:22:22 +02:00

Added support for terminal colors under Windows.

Tested on Python 2.7 under Windows 7 with PowerShell and cmd.exe.

Closes #36
This commit is contained in:
Jakub Roztocil 2012-07-17 03:48:10 +02:00
parent 54e3e5bca4
commit 2dba176aa8
3 changed files with 17 additions and 4 deletions

View File

@ -12,6 +12,7 @@ from . import cli
from . import pretty
TYPE_FORM = 'application/x-www-form-urlencoded; charset=utf-8'
TYPE_JSON = 'application/json; charset=utf-8'

View File

@ -9,15 +9,24 @@ from pygments.styles import get_style_by_name, STYLE_MAP
from pygments.lexers import get_lexer_for_mimetype, HttpLexer
from pygments.formatters.terminal256 import Terminal256Formatter
from pygments.formatters.terminal import TerminalFormatter
from requests.compat import is_windows
from . import solarized
if is_windows:
import colorama
colorama.init()
# 256 looks better on Windows
FORMATTER = Terminal256Formatter
else:
FORMATTER = (
Terminal256Formatter
if '256color' in os.environ.get('TERM', '')
else TerminalFormatter
)
DEFAULT_STYLE = 'solarized'
AVAILABLE_STYLES = [DEFAULT_STYLE] + list(STYLE_MAP.keys())
FORMATTER = (Terminal256Formatter
if '256color' in os.environ.get('TERM', '')
else TerminalFormatter)
application_content_type_re = re.compile(r'application/(.+\+)(json|xml)$')

View File

@ -17,6 +17,9 @@ requirements = [
if sys.version_info[:2] in ((2, 6), (3, 1)):
# argparse has been added in Python 3.2 / 2.7
requirements.append('argparse>=1.2.1')
if 'win32' in str(sys.platform).lower():
# Terminal colors for Windows
requirements.append('colorama>=0.2.4')
setup(