From 2faf460f0ff25b38723168fedce89987a94c4611 Mon Sep 17 00:00:00 2001 From: Ploum Date: Wed, 31 Jan 2024 16:30:49 +0100 Subject: [PATCH] close #39: implement --mode in opnk --- CHANGELOG | 1 + man/ansicat.1 | 2 ++ man/opnk.1 | 2 ++ opnk.py | 5 ++++- 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index bc4fb07..a335059 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,6 +12,7 @@ - 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 ## 2.1 - December 15th 2023 - freshly updated gemtext/rss links are highlighted ("new_link" theme option) diff --git a/man/ansicat.1 b/man/ansicat.1 index 14d71a4..e1161d0 100644 --- a/man/ansicat.1 +++ b/man/ansicat.1 @@ -54,6 +54,8 @@ either thanks to the MIME type, or from the file being rendered itself. .It Fl \-mime Ar MIME MIME type of the content to parse. +.It Fl \-mode Ar MODE +MODE to use to render to choose between normal (default), full or source .It Fl \-url Ar URL ... original URL of the content. .El diff --git a/man/opnk.1 b/man/opnk.1 index 079e1e7..0c0f9e6 100644 --- a/man/opnk.1 +++ b/man/opnk.1 @@ -37,6 +37,8 @@ path to the file or URL to open. .Bl -tag -width Ds -offset indent .It Fl h , \-help Show a help message and exit +.It Fl \-mode Ar MODE +MODE to use to render to choose between normal (default), full or source .El . .Sh EXIT STATUS diff --git a/opnk.py b/opnk.py index 1d2bb86..0fd2d1f 100755 --- a/opnk.py +++ b/opnk.py @@ -280,12 +280,15 @@ def main(): opnk will fallback to opening the file with xdg-open. If given an URL as input \ instead of a path, opnk will rely on netcache to get the networked content." parser = argparse.ArgumentParser(prog="opnk",description=descri) + parser.add_argument("--mode", metavar="MODE", + help="Which mode should be used to render: normal (default), full or source.\ + 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") args = parser.parse_args() cache = opencache() for f in args.content: - cache.opnk(f) + cache.opnk(f,mode=args.mode) if __name__ == "__main__": main()