git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
blob cfe0454d1de8113cd9f355a41d12752ff8a2580b 1644 bytes (raw)
name: generate-cmdlist.sh 	 # note: path name is non-authoritative(*)

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
 
#!/bin/sh

die () {
	echo "$@" >&2
	exit 1
}

command_list () {
	while read cmd rest
	do
		case "$cmd" in
		"#"* | '')
			# Ignore comments and allow empty lines
			continue
			;;
		*)
			case "$exclude_programs" in
			*":$cmd:"*)
				;;
			*)
				echo "$cmd $rest"
				;;
			esac
		esac
	done <"$1"
}

category_list () {
	command_list "$1" |
	cut -d' ' -f2- |
	tr ' ' '\012' |
	grep -v '^$' |
	LC_ALL=C sort -u
}

define_categories () {
	echo
	echo "/* Command categories */"
	bit=0
	category_list "$1" |
	while read cat
	do
		echo "#define CAT_$cat (1UL << $bit)"
		bit=$(($bit+1))
	done
	test "$bit" -gt 32 && die "Urgh.. too many categories?"
}

define_category_names () {
	echo
	echo "/* Category names */"
	echo "static const char *category_names[] = {"
	bit=0
	category_list "$1" |
	while read cat
	do
		echo "	\"$cat\", /* (1UL << $bit) */"
		bit=$(($bit+1))
	done
	echo "	NULL"
	echo "};"
}

print_command_list () {
	echo "static struct cmdname_help command_list[] = {"

	command_list "$1" |
	while read cmd rest
	do
		synopsis=
		while read line
		do
			case "$line" in
			"$cmd - "*)
				synopsis=${line#$cmd - }
				break
				;;
			esac
		done <"Documentation/$cmd.txt"

		printf '\t{ "%s", N_("%s"), 0' "$cmd" "$synopsis"
		printf " | CAT_%s" $rest
		echo " },"
	done
	echo "};"
}

exclude_programs=:
while test "--exclude-program" = "$1"
do
	shift
	exclude_programs="$exclude_programs$1:"
	shift
done

echo "/* Automatically generated by generate-cmdlist.sh */
struct cmdname_help {
	const char *name;
	const char *help;
	uint32_t category;
};
"
define_categories "$1"
echo
define_category_names "$1"
echo
print_command_list "$1"

debug log:

solving cfe0454d1de ...
found cfe0454d1de in https://80x24.org/mirrors/git.git

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).