Skip to content

Commit

Permalink
Merge pull request #16 from tictactix/master
Browse files Browse the repository at this point in the history
Added a way to force pretty printing
  • Loading branch information
jkbrzt committed Mar 4, 2012
2 parents 81568cf + 58f74fe commit d02ac54
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions httpie/httpie.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def __call__(self, string):
choices=pretty.AVAILABLE_STYLES,
help='Output coloring style, one of %s. Defaults to solarized.'
% ', '.join(sorted(pretty.AVAILABLE_STYLES)))

parser.add_argument('--pretty', '-p', help='Force pretty print.',
dest='force_pretty', action='store_true', default=False)

# ``requests.request`` keyword arguments.
parser.add_argument('--auth', '-a', help='username:password',
Expand Down Expand Up @@ -113,6 +114,7 @@ def main(args=None,
stdout_isatty=sys.stdout.isatty()):

args = parser.parse_args(args if args is not None else sys.argv[1:])
is_pretty = args.force_pretty or stdout_isatty

# Parse request headers and data from the command line.
headers = CaseInsensitiveDict()
Expand Down Expand Up @@ -175,7 +177,7 @@ def main(args=None,
response.content.decode(encoding) if response.content else u''
)

if args.prettify and stdout_isatty:
if args.prettify and is_pretty:
prettify = pretty.PrettyHttp(args.style)
if args.print_headers:
status_line = prettify.headers(status_line).strip()
Expand Down

0 comments on commit d02ac54

Please sign in to comment.