diff --git a/bin/swh-ls-tarball-size b/bin/swh-ls-tarball-size index 1eb8a77..ae23d47 100755 --- a/bin/swh-ls-tarball-size +++ b/bin/swh-ls-tarball-size @@ -1,32 +1,26 @@ #!/usr/bin/env python3 -# Copyright (C) 2015 The Software Heritage developers +# Copyright (C) 2015-2017 The Software Heritage developers # See the AUTHORS file at the top-level directory of this distribution # License: GNU General Public License version 3, or any later version # See top-level LICENSE file for more information -import argparse + +import click import os from swh.loader.tar import file -def parse_args(): +@click.command() +@click.option('--mirror-root-dir', required=1, help='path to the root dir.') +def main(mirror_root_dir): """Parse the configuration from the cli. """ - cli = argparse.ArgumentParser( - description='Tarball listing tarballs size.') - cli.add_argument('--mirror-root-dir', '-m', help='path to the root dir.') - - args = cli.parse_args() - - return args + for tarpath, _ in file.archives_from(mirror_root_dir): + print(tarpath, os.path.getsize(tarpath)) if __name__ == '__main__': - args = parse_args() - root_dir = args.mirror_root_dir - - for tarpath, _ in file.archives_from(root_dir): - print('%s %s' % (tarpath, os.path.getsize(tarpath))) + main()