1
0
mirror of https://github.com/httpie/cli.git synced 2025-08-10 22:42:05 +02:00

Changed default --print to "b" if stdout piped.

If the output is piped to another program or redirected to a file,
the new default behaviour is to only print the response body.
(It can still be overriden via the ``--print`` flag.)
This commit is contained in:
Jakub Roztocil
2012-07-20 23:43:04 +02:00
parent 7d82b853ae
commit 57fc606f6b
5 changed files with 58 additions and 18 deletions

View File

@@ -117,11 +117,14 @@ def main(args=None,
stdin=sys.stdin, stdin_isatty=sys.stdin.isatty(),
stdout=sys.stdout, stdout_isatty=sys.stdout.isatty()):
parser = cli.parser
args = parser.parse_args(
args=args if args is not None else sys.argv[1:],
stdin=stdin,
stdin_isatty=stdin_isatty
stdin_isatty=stdin_isatty,
stdout_isatty=stdout_isatty,
)
response = _get_response(args)
output = _get_output(args, stdout_isatty, response)
output_bytes = output.encode('utf8')