Skip to content

Commit

Permalink
Merge pull request #193 from chenliu0831/master
Browse files Browse the repository at this point in the history
Feature/output file CLI option "-o" similar to CURL
  • Loading branch information
okigan authored Mar 4, 2024
2 parents 2b9f163 + dabc1c7 commit 0676a50
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions awscurl/awscurl.py
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ def inner_main(argv):
parser.add_argument('--session_token', env_var='AWS_SESSION_TOKEN')
parser.add_argument('-L', '--location', action='store_true', default=False,
help="Follow redirects")
parser.add_argument('-o', '--output', metavar="<file>", help='Write to file instead of stdout', default='')

parser.add_argument('uri')

Expand Down Expand Up @@ -535,6 +536,12 @@ def inner_main(argv):

print(response.text)

if args.output:
filename = args.output
file_mode = "wb" if args.data_binary else "w"
with open(filename, file_mode) as f:
f.write(response.content)

exit_code = 0 if response.ok else 1

return exit_code
Expand Down

0 comments on commit 0676a50

Please sign in to comment.