From 504abfce63cac7fb59367a76eb4548dc8903f955 Mon Sep 17 00:00:00 2001 From: Harshit Bansal Date: Mon, 21 Aug 2017 23:11:19 +0530 Subject: [PATCH] zulip_tools.py: Add `GENERIC_CACHE_SCRIPT_PARSER`. This parser will act as a parent parser for all the cache cleaning scripts. --- scripts/lib/zulip_tools.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.py index 6f218f4e1d..135f0b83b1 100755 --- a/scripts/lib/zulip_tools.py +++ b/scripts/lib/zulip_tools.py @@ -1,5 +1,6 @@ #!/usr/bin/env python3 from __future__ import print_function +import argparse import datetime import errno import logging @@ -34,6 +35,19 @@ BLUE = '\x1b[34m' MAGENTA = '\x1b[35m' CYAN = '\x1b[36m' +# Parent parser for cache cleaning scripts. +GENERIC_CACHE_SCRIPT_PARSER = argparse.ArgumentParser(add_help=False) +GENERIC_CACHE_SCRIPT_PARSER.add_argument( + "--threshold", dest="threshold_days", type=int, default=14, + nargs="?", metavar="", help="Any cache which is not in " + "use by a deployment not older than threshold days(current " + "installation in dev) and older than threshold days will be " + "deleted. (defaults to 14)") +GENERIC_CACHE_SCRIPT_PARSER.add_argument( + "--dry-run", dest="dry_run", action="store_true", + help="If specified then script will only print the caches " + "that it will delete/keep back. It will not delete any cache.") + def get_deployment_version(extract_path): # type: (str) -> str version = '0.0.0'