2
0
mirror of https://github.com/xcat2/confluent.git synced 2024-11-22 01:22:00 +00:00

Add mechanism to supply data from argv

Some POST calls may want body from CLI, make this
easier by no longer requiring a file to do so.
This commit is contained in:
Jarrod Johnson 2021-03-16 11:18:46 -04:00
parent f2cb6ea535
commit aeb1b704b3

View File

@ -130,6 +130,8 @@ if __name__ == '__main__':
outf.write(chunk)
chunk = reader.read(16384)
sys.exit(0)
elif len(sys.argv) > 2 and not os.path.exists(sys.argv[-1]):
data = sys.argv[-1]
if os.path.exists(sys.argv[-1]):
data = open(sys.argv[-1]).read()
sys.stdout.write(HTTPSClient(json=json).grab_url(sys.argv[1], data).decode())