diff --git a/CHANGELOG b/CHANGELOG
index 087f43c..c745776 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -12,8 +12,9 @@
- offpunk: "gus" was broken, it is functionnal again
- opnk/offpunk: more informative prompt in less
- ansicat: added support for HTML description elements
and (by Bert Livens)
-- opnk: added "--mode" command-line argument (bug #37)
+- opnk: added "--mode" command-line argument (bug #39)
- offpunk: support for "preformatted" theming (bug #38)
+- opnk/netcache: added "--cache-validity" command-line argument (bug #37)
## 2.1 - December 15th 2023
- freshly updated gemtext/rss links are highlighted ("new_link" theme option)
diff --git a/man/netcache.1 b/man/netcache.1
index eeaf485..d7e3320 100644
--- a/man/netcache.1
+++ b/man/netcache.1
@@ -56,6 +56,8 @@ The value is expressed in megabytes.
.It Fl \-timeout Ar TIMEOUT
time to wait before cancelling connection.
The value is expressed in seconds.
+.It Fl \-cache-validity CACHE_VALIDITY
+Maximum age (in second) of the cached version before redownloading a new version.
.El
.
.Sh EXIT STATUS
diff --git a/man/opnk.1 b/man/opnk.1
index 0c0f9e6..a859b83 100644
--- a/man/opnk.1
+++ b/man/opnk.1
@@ -39,6 +39,8 @@ path to the file or URL to open.
Show a help message and exit
.It Fl \-mode Ar MODE
MODE to use to render to choose between normal (default), full or source
+.It Fl \-cache-validity CACHE_VALIDITY
+Maximum age (in second) of the cached version before redownloading a new version.
.El
.
.Sh EXIT STATUS
diff --git a/netcache.py b/netcache.py
index dd9e93d..7465f85 100755
--- a/netcache.py
+++ b/netcache.py
@@ -878,11 +878,12 @@ def main():
help="Cancel download of items above that size (value in Mb).")
parser.add_argument("--timeout", type=int,
help="Time to wait before cancelling connection (in second).")
+ parser.add_argument("--cache-validity",type=int, default=0,
+ help="maximum age, in second, of the cached version before \
+ redownloading a new version")
# No argument: write help
parser.add_argument('url', metavar='URL', nargs='*',
help='download URL and returns the content or the path to a cached version')
- # arg = URL: download and returns cached URI
- # --cache-validity : do not download if cache is valid
# --validity : returns the date of the cached version, Null if no version
# --force-download : download and replace cache, even if valid
args = parser.parse_args()
@@ -893,8 +894,8 @@ def main():
if args.offline:
path = get_cache_path(u)
else:
- print("Download URL: %s" %u)
- path,url = fetch(u,max_size=args.max_size,timeout=args.timeout)
+ path,url = fetch(u,max_size=args.max_size,timeout=args.timeout,\
+ validity=args.cache_validity)
if args.path:
print(path)
else:
diff --git a/opnk.py b/opnk.py
index 0fd2d1f..615a5d2 100755
--- a/opnk.py
+++ b/opnk.py
@@ -285,10 +285,13 @@ def main():
With HTML, the normal mode try to extract the article.")
parser.add_argument("content",metavar="INPUT", nargs="*",
default=sys.stdin, help="Path to the file or URL to open")
+ parser.add_argument("--cache-validity",type=int, default=0,
+ help="maximum age, in second, of the cached version before \
+ redownloading a new version")
args = parser.parse_args()
cache = opencache()
for f in args.content:
- cache.opnk(f,mode=args.mode)
+ cache.opnk(f,mode=args.mode,validity=args.cache_validity)
if __name__ == "__main__":
main()