Skip to content

Commit

Permalink
Fix terminal width detection
Browse files Browse the repository at this point in the history
Fixes #14
  • Loading branch information
jacebrowning committed Aug 19, 2016
1 parent 70428c9 commit 0cb0545
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,5 +1,9 @@
# Revision History

## 0.4 (unreleased)

- Fixed terminal width detection.

## 0.3 (2016/07/30)

- Added Windows support.
Expand Down
11 changes: 5 additions & 6 deletions coveragespace/cli.py
Expand Up @@ -14,15 +14,14 @@

from __future__ import unicode_literals

import os
import sys
import json

import six
from docopt import docopt
import colorama
from colorama import Fore, Style
import requests
import colorama
from backports.shutil_get_terminal_size import get_terminal_size

from . import API, VERSION

Expand Down Expand Up @@ -56,18 +55,18 @@ def call(slug, metric, value):

elif response.status_code == 422:
display("coverage decreased", response.json(),
Fore.YELLOW + Style.BRIGHT)
colorama.Fore.YELLOW + colorama.Style.BRIGHT)
return False

else:
display("coverage unknown", response.json(),
Fore.RED + Style.BRIGHT)
colorama.Fore.RED + colorama.Style.BRIGHT)
return False


def display(title, data, color=""):
"""Write colored text to the console."""
width = int(os.getenv('COLUMNS', 80))
width, _ = get_terminal_size()
six.print_(color + "{0:=^{1}}".format(' ' + title + ' ', width))
six.print_(color + json.dumps(data, indent=4))
six.print_(color + '=' * width)
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -3,3 +3,4 @@ six
docopt
colorama
requests
backports.shutil-get-terminal-size
3 changes: 3 additions & 0 deletions setup.py
Expand Up @@ -51,4 +51,7 @@
],

install_requires=open("requirements.txt").readlines(),
dependency_links = [
'https://github.com/chrippa/backports.shutil_get_terminal_size/tarball/159e269450dbf37c3a837f6ea7e628d59acbb96a#egg=backports.shutil-get-terminal-size'
]
)

0 comments on commit 0cb0545

Please sign in to comment.