blob: 5f1b7e488431c1ec401eb51bb559057ae5eeb8db [file] [log] [blame]
#!/usr/bin/env python3
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
"""Simpler helper to download files."""
import os
import sys
import libdot
def get_parser():
"""Get a command line parser."""
parser = libdot.ArgumentParser(description=__doc__)
parser.add_argument('--base64', action='store_true',
help='Decode file using base64.')
parser.add_argument('-o', '--output', type=str,
help='Alternative path to save to.')
parser.add_argument('args', nargs='+',
help='URIs or files to download.')
return parser
def main(argv):
"""The main func!"""
parser = get_parser()
opts = parser.parse_args(argv)
for uri in opts.args:
output = opts.output
if not output:
output = os.path.basename(uri)
libdot.fetch(uri, output, b64=opts.base64)
if __name__ == '__main__':
sys.exit(main(sys.argv[1:]))