mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-20 13:54:36 +01:00
Makefile: add check that manpage and command options match.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
8aca5c5d33
commit
626e9fed16
2 changed files with 44 additions and 0 deletions
|
@ -62,6 +62,11 @@ doc/full-states.dot: test/test_state_coverage
|
|||
|
||||
maintainer-clean: doc-maintainer-clean
|
||||
clean: doc-clean
|
||||
check: check-manpages
|
||||
|
||||
check-manpages: cli/lightning-cli lightningd/lightningd
|
||||
@tools/check-manpage.sh cli/lightning-cli doc/lightning-cli.1.txt
|
||||
@tools/check-manpage.sh lightningd/lightningd doc/lightningd-config.5.txt
|
||||
|
||||
doc-maintainer-clean:
|
||||
$(RM) doc/deployable-lightning.pdf
|
||||
|
|
39
tools/check-manpage.sh
Executable file
39
tools/check-manpage.sh
Executable file
|
@ -0,0 +1,39 @@
|
|||
#! /bin/bash
|
||||
# Needs bash for process substitition, ie <(
|
||||
|
||||
if [ $# != 2 ]; then
|
||||
echo "Usage $0 <command> <asciidoc.txt>" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
get_cmd_opts()
|
||||
{
|
||||
# Trim out -- after first one (--option mentioned in help!)
|
||||
$1 --help | grep '^-' | sed 's/[ ].*--.*//' | while IFS=$'\n' read -r opt; do
|
||||
case "$opt" in
|
||||
# We don't document dev options.
|
||||
--dev*)
|
||||
;;
|
||||
--*=*|--*' <arg>'*)
|
||||
echo "${opt%%[ =]*}=" | cut -c3-
|
||||
;;
|
||||
--*)
|
||||
echo "${opt%%[ |]*}" | cut -c3-
|
||||
;;
|
||||
-*\|--*)
|
||||
opt=${opt##*|}
|
||||
echo "${opt%%[ |]*}" | cut -c3-
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
CMD_OPTNAMES=$(get_cmd_opts "$1" | sort)
|
||||
|
||||
# Now, gather (long) opt names from man page, make sure they match.
|
||||
MAN_OPTNAMES=$(sed -n 's/^\*\(--\)\?\([^*/]*\)\*\(=\?\).*::/\2\3/p' < "$2" | sort)
|
||||
|
||||
if [ "$CMD_OPTNAMES" != "$MAN_OPTNAMES" ]; then
|
||||
echo "diff of command names vs manpage names":
|
||||
diff -u <(echo "$CMD_OPTNAMES") <(echo "$MAN_OPTNAMES")
|
||||
exit 2
|
||||
fi
|
Loading…
Add table
Reference in a new issue