Skip to content

Commit

Permalink
Added forcing pretty printing for piping purposes.
Browse files Browse the repository at this point in the history
  • Loading branch information
prafulfillment committed Mar 2, 2012
1 parent 860a851 commit 84a0d4a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions httpie/httpie.py
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_false', 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 @@ -174,7 +176,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 84a0d4a

Please sign in to comment.