diff options
author | Michał Górny <mgorny@gentoo.org> | 2017-11-02 09:34:49 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2017-11-02 09:34:49 +0100 |
commit | 93a159780da853f7b3c62eb805711f9275b7b393 (patch) | |
tree | 10597eec0516bf9a11d5b12604f15eda04c0c159 | |
parent | e0b34b56846d7749c9f28676f6c9dc85722f2ba3 (diff) | |
download | gemato-93a159780da853f7b3c62eb805711f9275b7b393.tar.gz |
cli: Require hashes only if profile does not set it
-rw-r--r-- | gemato/cli.py | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/gemato/cli.py b/gemato/cli.py index ab03995..a73d875 100644 --- a/gemato/cli.py +++ b/gemato/cli.py @@ -92,7 +92,8 @@ def do_update(args, argp): init_kwargs = {} save_kwargs = {} - init_kwargs['hashes'] = args.hashes.split() + if args.hashes is not None: + init_kwargs['hashes'] = args.hashes.split() if args.compress_watermark is not None: if args.compress_watermark < 0: argp.error('--compress-watermark must not be negative!') @@ -125,6 +126,10 @@ def do_update(args, argp): logging.error(str(e)) return 1 + # if not specified by user, profile must set it + if m.hashes is None: + argp.error('--hashes must be specified if not implied by --profile') + relpath = os.path.relpath(p, os.path.dirname(tlm)) if relpath == '.': relpath = '' @@ -153,7 +158,8 @@ def do_create(args, argp): init_kwargs = {} save_kwargs = {} init_kwargs['allow_create'] = True - init_kwargs['hashes'] = args.hashes.split() + if args.hashes is not None: + init_kwargs['hashes'] = args.hashes.split() if args.compress_watermark is not None: if args.compress_watermark < 0: argp.error('--compress-watermark must not be negative!') @@ -186,6 +192,10 @@ def do_create(args, argp): logging.error(str(e)) return 1 + # if not specified by user, profile must set it + if m.hashes is None: + argp.error('--hashes must be specified if not implied by --profile') + try: m.update_entries_for_directory() @@ -240,7 +250,7 @@ def main(argv): help='Format for compressed files (e.g. "gz", "bz2"...)') update.add_argument('-f', '--force-rewrite', action='store_true', help='Force rewriting all the Manifests, even if they did not change') - update.add_argument('-H', '--hashes', required=True, + update.add_argument('-H', '--hashes', help='Whitespace-separated list of hashes to use') update.add_argument('-k', '--openpgp-id', help='Use the specified OpenPGP key (by ID or user)') @@ -267,7 +277,7 @@ def main(argv): help='Format for compressed files (e.g. "gz", "bz2"...)') create.add_argument('-f', '--force-rewrite', action='store_true', help='Force rewriting all the Manifests, even if they did not change') - create.add_argument('-H', '--hashes', required=True, + create.add_argument('-H', '--hashes', help='Whitespace-separated list of hashes to use') create.add_argument('-k', '--openpgp-id', help='Use the specified OpenPGP key (by ID or user)') |