close #39: implement --mode in opnk

This commit is contained in:
Ploum 2024-01-31 16:30:49 +01:00
parent 6484cf3426
commit 2faf460f0f
4 changed files with 9 additions and 1 deletions

View File

@ -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 <dt> and <dd> (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)

View File

@ -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

View File

@ -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

View File

@ -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()