]> git.ipfire.org Git - thirdparty/rsync.git/blob - help-from-md.awk
More tweaks for Actions.
[thirdparty/rsync.git] / help-from-md.awk
1 #!/usr/bin/awk -f
2
3 # The caller must pass args: -v hfile=help-NAME.h NAME.NUM.md
4
5 BEGIN {
6 heading = "/* DO NOT EDIT THIS FILE! It is auto-generated from the option list in " ARGV[1] "! */"
7 findcomment = hfile
8 sub("\\.", "\\.", findcomment)
9 findcomment = "\\[comment\\].*" findcomment
10 backtick_cnt = 0
11 prints = ""
12 }
13
14 /^```/ {
15 backtick_cnt++
16 next
17 }
18
19 foundcomment {
20 if (backtick_cnt > 1) exit
21 if (backtick_cnt == 1) {
22 gsub(/"/, "\\\"")
23 prints = prints "\n rprintf(F,\"" $0 "\\n\");"
24 }
25 next
26 }
27
28 $0 ~ findcomment {
29 foundcomment = 1
30 backtick_cnt = 0
31 }
32
33 END {
34 if (foundcomment && backtick_cnt > 1)
35 print heading "\n" prints > hfile
36 else {
37 print "Failed to find " hfile " section in " ARGV[1]
38 exit 1
39 }
40 }