mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2025-01-20 23:18:34 +01:00
Autogenerate dependency table
This commit is contained in:
parent
ff40b0a143
commit
897aa38fca
8
Makefile
8
Makefile
@ -14,7 +14,7 @@ LIBS := magic crypto
|
||||
CFLAGS += $(O) -MD -Wall -Wextra -Wno-unused-parameter
|
||||
LDFLAGS += $(LIBS:%=-l%)
|
||||
|
||||
all: ctpv
|
||||
all: ctpv README.md doc/ctpv.1
|
||||
|
||||
options:
|
||||
@echo "CC = $(CC)"
|
||||
@ -58,6 +58,12 @@ gen/helpers.h: helpers.sh embed/embed
|
||||
@mkdir -p $(@D)
|
||||
embed/embed -p scr_ helpers.sh > $@
|
||||
|
||||
README.md: $(PRE)
|
||||
./deplist.awk $^ | ./deplist.md.sh | ./deplistadd.sh $@
|
||||
|
||||
doc/ctpv.1: $(PRE)
|
||||
./deplist.awk $^ | ./deplist.1.sh | ./deplistadd.sh $@
|
||||
|
||||
embed/embed: make_embed
|
||||
@ # do nothing
|
||||
|
||||
|
35
README.md
35
README.md
@ -23,22 +23,29 @@ external programs like lf does.
|
||||
|
||||
## Dependencies
|
||||
|
||||
These programs are needed to make specific previews work.
|
||||
If a preview requires some program and it's not found on the system,
|
||||
`ctpv` will fallback to other previews.
|
||||
All the previews require specific programs to function.
|
||||
If a required program is not found on the system, ctpv
|
||||
will try to use another preview.
|
||||
|
||||
| File types | Required programs |
|
||||
<!-- This table is auto generated! -->
|
||||
<!--TABLESTART-->
|
||||
| File types | Programs |
|
||||
| ---- | ---- |
|
||||
| Text files | `source-highlight` `highlight` |
|
||||
| Image files | `ueberzug` |
|
||||
| Videos | `ffmpegthumbnailer` |
|
||||
| Diff files | `colordiff` `delta` `diff-so-fancy` |
|
||||
| Markdown | `mdcat` |
|
||||
| JSON files | `jq` |
|
||||
| PDF files | `pdftoppm` |
|
||||
| Torrent files | `transmission-show` |
|
||||
| HTML files | `w3m` `lynx` `elinks` |
|
||||
| Any other files | `exiftool` |
|
||||
| any | `exiftool` `cat` |
|
||||
| archive | `atool` |
|
||||
| diff | `colordiff` `delta` `diff-so-fancy` |
|
||||
| directory | `ls` |
|
||||
| html | `elinks` `lynx` `w3m` |
|
||||
| image | `ueberzug` |
|
||||
| json | `jq` |
|
||||
| libreoffice | `libreoffice` |
|
||||
| markdown | `mdcat` |
|
||||
| pdf | `pdftoppm` |
|
||||
| text | `bat` `cat` `highlight` `source-highlight` |
|
||||
| torrent | `transmission-show` |
|
||||
| video | `ffmpegthumbnailer` |
|
||||
|
||||
<!--TABLEEND-->
|
||||
|
||||
## Installation
|
||||
|
||||
|
11
deplist.1.sh
Executable file
11
deplist.1.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo '.TS'
|
||||
echo 'allbox;'
|
||||
echo 'lb lb'
|
||||
echo 'l li .'
|
||||
|
||||
printf '%s\t%s\n' 'File type' 'Programs'
|
||||
sort | sed 's/\t/&T{\n/; s/$/\nT}/'
|
||||
|
||||
echo '.TE'
|
43
deplist.awk
Executable file
43
deplist.awk
Executable file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/gawk -f
|
||||
|
||||
function perr(str) {
|
||||
printf "%s: %s\n", ARGV[0], str > "/dev/stderr"
|
||||
}
|
||||
|
||||
function join(arr, sep, res, s) {
|
||||
for (i in arr) {
|
||||
res = res s arr[i]
|
||||
if (s == "")
|
||||
s = sep
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
function process_file(file, i, line, arr, t, p, p_len) {
|
||||
i = getline line < file
|
||||
|
||||
if (i == -1) {
|
||||
perr(ERRNO ": " file)
|
||||
exit
|
||||
} else if (i == 0) {
|
||||
return
|
||||
}
|
||||
|
||||
if (match(line, /^#\s*(\w+):\s*(.*)/, arr) == 0)
|
||||
return
|
||||
|
||||
t = arr[1]
|
||||
p_len = split(arr[2], p, /\s+/)
|
||||
for (i = 1; i <= p_len; i++)
|
||||
types[t][types_len[t]++] = p[i]
|
||||
}
|
||||
|
||||
BEGIN {
|
||||
for (i = 1; i < ARGC; i++)
|
||||
process_file(ARGV[i])
|
||||
|
||||
for (t in types) {
|
||||
printf "%s\t%s\n", t, join(types[t], " ")
|
||||
}
|
||||
}
|
7
deplist.md.sh
Executable file
7
deplist.md.sh
Executable file
@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "| File types | Programs |"
|
||||
echo "| ---- | ---- |"
|
||||
|
||||
sort | sed 's/ /` `/g; s/^/| /; s/\t/ | `/; s/$/` |/'
|
||||
echo
|
16
deplistadd.sh
Executable file
16
deplistadd.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
|
||||
table="$(mktemp XXXXXX)"
|
||||
trap 'rm "$table"' EXIT
|
||||
|
||||
cat > "$table"
|
||||
|
||||
sed -i "
|
||||
/TABLESTART/,/TABLEEND/ {
|
||||
/TABLESTART/ {
|
||||
r $table
|
||||
b
|
||||
}
|
||||
/TABLEEND/!d
|
||||
}
|
||||
" "$1"
|
56
doc/ctpv.1
56
doc/ctpv.1
@ -1,3 +1,4 @@
|
||||
'\" t
|
||||
.ds op \&.\|.\|.\&
|
||||
.
|
||||
.de Sy
|
||||
@ -76,6 +77,61 @@ is given a file, it determines an appropriate preview for it and
|
||||
runs its script.
|
||||
The script produces preview content and prints it to standard output.
|
||||
.
|
||||
.SS Dependencies
|
||||
.
|
||||
All the previews require specific programs to function.
|
||||
If a required program is not found on the system,
|
||||
.B ctpv
|
||||
will try to use another preview.
|
||||
\# This table is auto generated!
|
||||
\# TABLESTART
|
||||
.TS
|
||||
allbox;
|
||||
lb lb
|
||||
l li .
|
||||
File type Programs
|
||||
any T{
|
||||
exiftool cat
|
||||
T}
|
||||
archive T{
|
||||
atool
|
||||
T}
|
||||
diff T{
|
||||
colordiff delta diff-so-fancy
|
||||
T}
|
||||
directory T{
|
||||
ls
|
||||
T}
|
||||
html T{
|
||||
elinks lynx w3m
|
||||
T}
|
||||
image T{
|
||||
ueberzug
|
||||
T}
|
||||
json T{
|
||||
jq
|
||||
T}
|
||||
libreoffice T{
|
||||
libreoffice
|
||||
T}
|
||||
markdown T{
|
||||
mdcat
|
||||
T}
|
||||
pdf T{
|
||||
pdftoppm
|
||||
T}
|
||||
text T{
|
||||
bat cat highlight source-highlight
|
||||
T}
|
||||
torrent T{
|
||||
transmission-show
|
||||
T}
|
||||
video T{
|
||||
ffmpegthumbnailer
|
||||
T}
|
||||
.TE
|
||||
\# TABLEEND
|
||||
.
|
||||
.SS Integration
|
||||
.
|
||||
.TP
|
||||
|
@ -1,3 +1,5 @@
|
||||
# any: exiftool cat
|
||||
|
||||
if exists exiftool; then
|
||||
exiftool -- "$f" || true
|
||||
else
|
||||
|
@ -1 +1,3 @@
|
||||
# archive: atool
|
||||
|
||||
atool -l -- "$f"
|
||||
|
@ -1,3 +1,5 @@
|
||||
# text: bat
|
||||
|
||||
if exists bat; then
|
||||
batcmd=bat
|
||||
elif exists batcat; then
|
||||
|
@ -1 +1,3 @@
|
||||
# text: cat
|
||||
|
||||
cat < "$f"
|
||||
|
@ -1 +1,3 @@
|
||||
# diff: colordiff
|
||||
|
||||
colordiff < "$f"
|
||||
|
@ -1 +1,3 @@
|
||||
# diff: delta
|
||||
|
||||
delta < "$f"
|
||||
|
@ -1 +1,3 @@
|
||||
# diff: diff-so-fancy
|
||||
|
||||
diff-so-fancy < "$f"
|
||||
|
@ -1,3 +1,5 @@
|
||||
# html: elinks
|
||||
|
||||
elinks \
|
||||
-dump 1 -dump-width "$w" \
|
||||
-no-references -no-numbering < "$f"
|
||||
|
@ -1,3 +1,5 @@
|
||||
# text: highlight
|
||||
|
||||
highlight \
|
||||
--replace-tabs=4 --out-format=ansi \
|
||||
--style='pablo' --force -- "$f"
|
||||
|
@ -1 +1,3 @@
|
||||
# json: jq
|
||||
|
||||
jq -C . < "$f"
|
||||
|
@ -1 +1,3 @@
|
||||
# directory: ls
|
||||
|
||||
ls --color --group-directories-first -- "$f"
|
||||
|
@ -1 +1,3 @@
|
||||
# html: lynx
|
||||
|
||||
lynx -dump -nonumbers -nolist -width="$w" -- "$f"
|
||||
|
@ -1 +1,3 @@
|
||||
# markdown: mdcat
|
||||
|
||||
mdcat --columns "$w" -- "$f"
|
||||
|
@ -1,4 +1,4 @@
|
||||
# libreoffice
|
||||
# libreoffice: libreoffice
|
||||
|
||||
office() {
|
||||
# File produced by libreoffice
|
||||
|
@ -1,3 +1,5 @@
|
||||
# pdf: pdftoppm
|
||||
|
||||
pdf() {
|
||||
pdftoppm -f 1 -l 1 \
|
||||
-scale-to-x 1920 \
|
||||
|
@ -1,3 +1,5 @@
|
||||
# text: source-highlight
|
||||
|
||||
source-highlight \
|
||||
--tab=4 --out-format=esc \
|
||||
--style=esc256.style --failsafe -i \
|
||||
|
@ -1 +1,3 @@
|
||||
# torrent: transmission-show
|
||||
|
||||
transmission-show -- "$f"
|
||||
|
@ -1,3 +1,5 @@
|
||||
# image: ueberzug
|
||||
|
||||
setup_fifo
|
||||
|
||||
send_image "$f"
|
||||
|
@ -1,3 +1,5 @@
|
||||
# video: ffmpegthumbnailer
|
||||
|
||||
video() {
|
||||
ffmpegthumbnailer -i "$f" -o "$cache_f" -s 0 -t 50% 2>/dev/null
|
||||
}
|
||||
|
@ -1 +1,3 @@
|
||||
# html: w3m
|
||||
|
||||
w3m -dump "$f"
|
||||
|
Loading…
Reference in New Issue
Block a user