Debian / debiman

debiman generates a static manpage HTML repository out of a Debian archive
Apache License 2.0
195 stars 46 forks source link

programmatically query manpage details #49

Open lnxbil opened 7 years ago

lnxbil commented 7 years ago

Hi,

is there a way to query a raw manpage directly only by its (unambiguous) name? I want to use it from the CLI.

Best, Andreas

stapelberg commented 7 years ago

Yes: for every .html file, there is a corresponding .gz file containing the raw manpage. Hence, you can fetch e.g. https://manpages.debian.org/bash, which results in a temporary redirect to /jessie/bash/bash.1.en.html. Replace the html with gz, and you’ll get the raw manpage:

curl -s https://manpages.debian.org/jessie/bash/bash.1.en.gz | man /dev/stdin

Hope that helps!

lnxbil commented 7 years ago

Thanks, that works ... should I open another issue for the ambiguous case?

stapelberg commented 7 years ago

Not sure I follow. When things are ambiguous, what would you like to do?

lnxbil commented 7 years ago

I'd like to get the same alternatives that are displayed right now, but in text form, e.g. a simple list wrapped in JSON or some other format. That should be discussed, but it would be a great feature to open all manpages through the debiman service from the commandline.

I use vimpager and your command does not provide a working sample for that. The manpage is just simple text as a block. I only got a command not working as a pipe, but with a temporary file:

wget -O /tmp/manpage -q https://manpages.debian.org/testing/zfsutils-linux/zfs.8.en.gz ; \
vim -c 'set ft=man' -c ':Man /tmp/manpage'
stapelberg commented 7 years ago

Let me dwell on the best way to implement this feature for a little while. My current idea is to provide a .json file with everything we know about a manpage (i.e. we’ll have html, gz and json).

lnxbil commented 7 years ago

Perfect!