mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2025-06-24 03:41:44 +02: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
|
CFLAGS += $(O) -MD -Wall -Wextra -Wno-unused-parameter
|
||||||
LDFLAGS += $(LIBS:%=-l%)
|
LDFLAGS += $(LIBS:%=-l%)
|
||||||
|
|
||||||
all: ctpv
|
all: ctpv README.md doc/ctpv.1
|
||||||
|
|
||||||
options:
|
options:
|
||||||
@echo "CC = $(CC)"
|
@echo "CC = $(CC)"
|
||||||
@ -58,6 +58,12 @@ gen/helpers.h: helpers.sh embed/embed
|
|||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
embed/embed -p scr_ helpers.sh > $@
|
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
|
embed/embed: make_embed
|
||||||
@ # do nothing
|
@ # do nothing
|
||||||
|
|
||||||
|
35
README.md
35
README.md
@ -23,22 +23,29 @@ external programs like lf does.
|
|||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
These programs are needed to make specific previews work.
|
All the previews require specific programs to function.
|
||||||
If a preview requires some program and it's not found on the system,
|
If a required program is not found on the system, ctpv
|
||||||
`ctpv` will fallback to other previews.
|
will try to use another preview.
|
||||||
|
|
||||||
| File types | Required programs |
|
<!-- This table is auto generated! -->
|
||||||
|
<!--TABLESTART-->
|
||||||
|
| File types | Programs |
|
||||||
| ---- | ---- |
|
| ---- | ---- |
|
||||||
| Text files | `source-highlight` `highlight` |
|
| any | `exiftool` `cat` |
|
||||||
| Image files | `ueberzug` |
|
| archive | `atool` |
|
||||||
| Videos | `ffmpegthumbnailer` |
|
| diff | `colordiff` `delta` `diff-so-fancy` |
|
||||||
| Diff files | `colordiff` `delta` `diff-so-fancy` |
|
| directory | `ls` |
|
||||||
| Markdown | `mdcat` |
|
| html | `elinks` `lynx` `w3m` |
|
||||||
| JSON files | `jq` |
|
| image | `ueberzug` |
|
||||||
| PDF files | `pdftoppm` |
|
| json | `jq` |
|
||||||
| Torrent files | `transmission-show` |
|
| libreoffice | `libreoffice` |
|
||||||
| HTML files | `w3m` `lynx` `elinks` |
|
| markdown | `mdcat` |
|
||||||
| Any other files | `exiftool` |
|
| pdf | `pdftoppm` |
|
||||||
|
| text | `bat` `cat` `highlight` `source-highlight` |
|
||||||
|
| torrent | `transmission-show` |
|
||||||
|
| video | `ffmpegthumbnailer` |
|
||||||
|
|
||||||
|
<!--TABLEEND-->
|
||||||
|
|
||||||
## Installation
|
## 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 \&.\|.\|.\&
|
.ds op \&.\|.\|.\&
|
||||||
.
|
.
|
||||||
.de Sy
|
.de Sy
|
||||||
@ -76,6 +77,61 @@ is given a file, it determines an appropriate preview for it and
|
|||||||
runs its script.
|
runs its script.
|
||||||
The script produces preview content and prints it to standard output.
|
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
|
.SS Integration
|
||||||
.
|
.
|
||||||
.TP
|
.TP
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# any: exiftool cat
|
||||||
|
|
||||||
if exists exiftool; then
|
if exists exiftool; then
|
||||||
exiftool -- "$f" || true
|
exiftool -- "$f" || true
|
||||||
else
|
else
|
||||||
|
@ -1 +1,3 @@
|
|||||||
|
# archive: atool
|
||||||
|
|
||||||
atool -l -- "$f"
|
atool -l -- "$f"
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# text: bat
|
||||||
|
|
||||||
if exists bat; then
|
if exists bat; then
|
||||||
batcmd=bat
|
batcmd=bat
|
||||||
elif exists batcat; then
|
elif exists batcat; then
|
||||||
|
@ -1 +1,3 @@
|
|||||||
|
# text: cat
|
||||||
|
|
||||||
cat < "$f"
|
cat < "$f"
|
||||||
|
@ -1 +1,3 @@
|
|||||||
|
# diff: colordiff
|
||||||
|
|
||||||
colordiff < "$f"
|
colordiff < "$f"
|
||||||
|
@ -1 +1,3 @@
|
|||||||
|
# diff: delta
|
||||||
|
|
||||||
delta < "$f"
|
delta < "$f"
|
||||||
|
@ -1 +1,3 @@
|
|||||||
|
# diff: diff-so-fancy
|
||||||
|
|
||||||
diff-so-fancy < "$f"
|
diff-so-fancy < "$f"
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# html: elinks
|
||||||
|
|
||||||
elinks \
|
elinks \
|
||||||
-dump 1 -dump-width "$w" \
|
-dump 1 -dump-width "$w" \
|
||||||
-no-references -no-numbering < "$f"
|
-no-references -no-numbering < "$f"
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# text: highlight
|
||||||
|
|
||||||
highlight \
|
highlight \
|
||||||
--replace-tabs=4 --out-format=ansi \
|
--replace-tabs=4 --out-format=ansi \
|
||||||
--style='pablo' --force -- "$f"
|
--style='pablo' --force -- "$f"
|
||||||
|
@ -1 +1,3 @@
|
|||||||
|
# json: jq
|
||||||
|
|
||||||
jq -C . < "$f"
|
jq -C . < "$f"
|
||||||
|
@ -1 +1,3 @@
|
|||||||
|
# directory: ls
|
||||||
|
|
||||||
ls --color --group-directories-first -- "$f"
|
ls --color --group-directories-first -- "$f"
|
||||||
|
@ -1 +1,3 @@
|
|||||||
|
# html: lynx
|
||||||
|
|
||||||
lynx -dump -nonumbers -nolist -width="$w" -- "$f"
|
lynx -dump -nonumbers -nolist -width="$w" -- "$f"
|
||||||
|
@ -1 +1,3 @@
|
|||||||
|
# markdown: mdcat
|
||||||
|
|
||||||
mdcat --columns "$w" -- "$f"
|
mdcat --columns "$w" -- "$f"
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# libreoffice
|
# libreoffice: libreoffice
|
||||||
|
|
||||||
office() {
|
office() {
|
||||||
# File produced by libreoffice
|
# File produced by libreoffice
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# pdf: pdftoppm
|
||||||
|
|
||||||
pdf() {
|
pdf() {
|
||||||
pdftoppm -f 1 -l 1 \
|
pdftoppm -f 1 -l 1 \
|
||||||
-scale-to-x 1920 \
|
-scale-to-x 1920 \
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# text: source-highlight
|
||||||
|
|
||||||
source-highlight \
|
source-highlight \
|
||||||
--tab=4 --out-format=esc \
|
--tab=4 --out-format=esc \
|
||||||
--style=esc256.style --failsafe -i \
|
--style=esc256.style --failsafe -i \
|
||||||
|
@ -1 +1,3 @@
|
|||||||
|
# torrent: transmission-show
|
||||||
|
|
||||||
transmission-show -- "$f"
|
transmission-show -- "$f"
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# image: ueberzug
|
||||||
|
|
||||||
setup_fifo
|
setup_fifo
|
||||||
|
|
||||||
send_image "$f"
|
send_image "$f"
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
# video: ffmpegthumbnailer
|
||||||
|
|
||||||
video() {
|
video() {
|
||||||
ffmpegthumbnailer -i "$f" -o "$cache_f" -s 0 -t 50% 2>/dev/null
|
ffmpegthumbnailer -i "$f" -o "$cache_f" -s 0 -t 50% 2>/dev/null
|
||||||
}
|
}
|
||||||
|
@ -1 +1,3 @@
|
|||||||
|
# html: w3m
|
||||||
|
|
||||||
w3m -dump "$f"
|
w3m -dump "$f"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user