commit 63eda621ba3d2ebe9b75c7c2d4298b72de935252 from: Stefan Sperling date: Mon Sep 25 13:14:37 2023 UTC generate man command tab-completion table with a script at build-time This prevents the table from becoming out of date going forward. There were a few tags in nsh.8 which weren't yet being displayed: + { "inet6", "Search for tag inet6", CMPL0 NULL, 0 }, + { "powerdown", "Search for tag powerdown", CMPL0 NULL, 0 }, + { "saveenv", "Search for tag saveenv", CMPL0 NULL, 0 }, And an error has been corrected: - { "unsetenv", "Search for tag setenv", CMPL0 NULL, 0 }, + { "unsetenv", "Search for tag unsetenv", CMPL0 NULL, 0 }, commit - 16a04e0fcc6f8084731bf3279fff9f2a422bad4a commit + 63eda621ba3d2ebe9b75c7c2d4298b72de935252 blob - 46621f5ef859b66fa6d9d8d03658b3274837aa1a blob + 3e60e45d7330318e8ab44679194c37b4b909a023 --- Makefile +++ Makefile @@ -29,8 +29,8 @@ SRCS+=ctl.c show.c if.c version.c route.c conf.c compl SRCS+=bridge.c tunnel.c media.c sysctl.c passwd.c pfsync.c carp.c SRCS+=trunk.c who.c more.c stringlist.c utils.c sqlite3.c ppp.c prompt.c SRCS+=nopt.c pflow.c wg.c nameserver.c ndp.c umb.c utf8.c cmdargs.c ctlargs.c -SRCS+=helpcommands.c makeargv.c hashtable.c -CLEANFILES+=compile.c +SRCS+=helpcommands.c makeargv.c hashtable.c mantab.c +CLEANFILES+=compile.c mantab.c LDADD=-lutil -ledit -ltermcap -lsqlite3 -L/usr/local/lib #-static MAN=nsh.8 @@ -38,6 +38,9 @@ MAN=nsh.8 compile.c: compile.sh sh ${.CURDIR}/compile.sh +mantab.c: mantab.sh nsh.8 + sh ${.CURDIR}/mantab.sh ${.CURDIR}/nsh.8 > mantab.c + release: clean sed -i -e "s/_RELEASE=No/_RELEASE=Yes/" ${.CURDIR}/nsh-version.mk ${MAKE} -C ${.CURDIR} dist blob - 10708daf18f31248cb47bdfec873ce1807bc56a1 blob + 7204cdd776c24d46383df73c5c9e70d9df04d819 --- commands.c +++ commands.c @@ -1085,7 +1085,7 @@ static char verbosehelp[]; static char editinghelp[]; static char shellhelp[]; static char manhelp[]; -struct ghs mantab[]; +extern struct ghs mantab[]; struct intlist Intlist[] = { /* Interface mode commands */ @@ -1788,158 +1788,6 @@ struct ghs demotecountertab[] = { Menu grouptab[] = { { "carpdemote", "Set carp demote counter", CMPL(h) (char **)demotecountertab, sizeof(struct ghs), 0, 0, group }, { 0, 0, 0, 0, 0 } -}; - -/* Keep in sync with grep '^\.Tg' nsh.8 | sort | uniq */ -struct ghs mantab[] = { - { "ah", "Search for tag ah", CMPL0 NULL, 0 }, - { "arp", "Search for tag arp", CMPL0 NULL, 0 }, - { "auth", "Search for tag auth", CMPL0 NULL, 0 }, - { "autoconf", "Search for tag autoconf", CMPL0 NULL, 0 }, - { "bgp", "Search for tag bgp", CMPL0 NULL, 0 }, - { "bgpctl", "Search for tag bgpctl", CMPL0 NULL, 0 }, - { "bgpd", "Search for tag bgpd", CMPL0 NULL, 0 }, - { "bridge", "Search for tag bridge", CMPL0 NULL, 0 }, - { "bridgeport", "Search for tag bridgeport", CMPL0 NULL, 0 }, - { "carp", "Search for tag carp", CMPL0 NULL, 0 }, - { "config", "Search for tag config", CMPL0 NULL, 0 }, - { "configure", "Search for tag configure", CMPL0 NULL, 0 }, - { "crontab", "Search for tag crontab", CMPL0 NULL, 0 }, - { "csh", "Search for tag csh", CMPL0 NULL, 0 }, - { "ddb", "Search for tag ddb", CMPL0 NULL, 0 }, - { "dhcp", "Search for tag dhcp", CMPL0 NULL, 0 }, - { "dhcpd", "Search for tag dhcpd", CMPL0 NULL, 0 }, - { "dhcprelay", "Search for tag dhcprelay", CMPL0 NULL, 0 }, - { "dhcrelay", "Search for tag dhcrelay", CMPL0 NULL, 0 }, - { "disable", "Search for tag disable", CMPL0 NULL, 0 }, - { "dvmrp", "Search for tag dvmrp", CMPL0 NULL, 0 }, - { "dvmrpd", "Search for tag dvmrpd", CMPL0 NULL, 0 }, - { "editing", "Search for tag editing", CMPL0 NULL, 0 }, - { "eigrp", "Search for tag eigrp", CMPL0 NULL, 0 }, - { "eigrpd", "Search for tag eigrpd", CMPL0 NULL, 0 }, - { "enable", "Search for tag enable", CMPL0 NULL, 0 }, - { "esp", "Search for tag esp", CMPL0 NULL, 0 }, - { "firewall", "Search for tag firewall", CMPL0 NULL, 0 }, - { "flow", "Search for tag flow", CMPL0 NULL, 0 }, - { "flush", "Search for tag flush", CMPL0 NULL, 0 }, - { "ftp-proxy", "Search for tag ftp-proxy", CMPL0 NULL, 0 }, - { "group", "Search for tag group", CMPL0 NULL, 0 }, - { "halt", "Search for tag halt", CMPL0 NULL, 0 }, - { "help", "Search for tag help", CMPL0 NULL, 0 }, - { "hostname", "Search for tag hostname", CMPL0 NULL, 0 }, - { "hsrp", "Search for tag hsrp", CMPL0 NULL, 0 }, - { "icmp", "Search for tag icmp", CMPL0 NULL, 0 }, - { "ifstate", "Search for tag ifstate", CMPL0 NULL, 0 }, - { "ifstated", "Search for tag ifstated", CMPL0 NULL, 0 }, - { "igmp", "Search for tag igmp", CMPL0 NULL, 0 }, - { "ike", "Search for tag ike", CMPL0 NULL, 0 }, - { "iked", "Search for tag iked", CMPL0 NULL, 0 }, - { "ikev2", "Search for tag ikev2", CMPL0 NULL, 0 }, - { "inet", "Search for tag inet", CMPL0 NULL, 0 }, - { "inetd", "Search for tag inetd", CMPL0 NULL, 0 }, - { "interface", "Search for tag interface", CMPL0 NULL, 0 }, - { "ip", "Search for tag ip", CMPL0 NULL, 0 }, - { "ip6", "Search for tag ip6", CMPL0 NULL, 0 }, - { "ipcomp", "Search for tag ipcomp", CMPL0 NULL, 0 }, - { "ipsec", "Search for tag ipsec", CMPL0 NULL, 0 }, - { "isakmpd", "Search for tag isakmpd", CMPL0 NULL, 0 }, - { "isolation", "Search for tag isolation", CMPL0 NULL, 0 }, - { "kernel", "Search for tag kernel", CMPL0 NULL, 0 }, - { "ksh", "Search for tag ksh", CMPL0 NULL, 0 }, - { "l2vpn", "Search for tag l2vpn", CMPL0 NULL, 0 }, - { "label", "Search for tag label", CMPL0 NULL, 0 }, - { "layer2", "Search for tag layer2", CMPL0 NULL, 0 }, - { "ldap", "Search for tag ldap", CMPL0 NULL, 0 }, - { "ldapd", "Search for tag ldapd", CMPL0 NULL, 0 }, - { "ldp", "Search for tag ldp", CMPL0 NULL, 0 }, - { "ldpd", "Search for tag ldpd", CMPL0 NULL, 0 }, - { "lease", "Search for tag lease", CMPL0 NULL, 0 }, - { "lladdr", "Search for tag lladdr", CMPL0 NULL, 0 }, - { "macaddress", "Search for tag macaddress", CMPL0 NULL, 0 }, - { "manual", "Search for tag manual", CMPL0 NULL, 0 }, - { "mbuf", "Search for tag mbuf", CMPL0 NULL, 0 }, - { "monitor", "Search for tag monitor", CMPL0 NULL, 0 }, - { "mpls", "Search for tag mpls", CMPL0 NULL, 0 }, - { "multicast", "Search for tag multicast", CMPL0 NULL, 0 }, - { "nameserver", "Search for tag nameserver", CMPL0 NULL, 0 }, - { "ndp", "Search for tag ndp", CMPL0 NULL, 0 }, - { "nppp", "Search for tag nppp", CMPL0 NULL, 0 }, - { "npppd", "Search for tag npppd", CMPL0 NULL, 0 }, - { "ntp", "Search for tag ntp", CMPL0 NULL, 0 }, - { "ntpd", "Search for tag ntpd", CMPL0 NULL, 0 }, - { "ospf", "Search for tag ospf", CMPL0 NULL, 0 }, - { "ospf6", "Search for tag ospf6", CMPL0 NULL, 0 }, - { "ospfv3", "Search for tag ospfv3", CMPL0 NULL, 0 }, - { "packetfilter", "Search for tag packetfilter", CMPL0 NULL, 0 }, - { "pair", "Search for tag pair", CMPL0 NULL, 0 }, - { "patch", "Search for tag patch", CMPL0 NULL, 0 }, - { "pf", "Search for tag pf", CMPL0 NULL, 0 }, - { "pfsync", "Search for tag pfsync", CMPL0 NULL, 0 }, - { "ping", "Search for tag ping", CMPL0 NULL, 0 }, - { "ping6", "Search for tag ping6", CMPL0 NULL, 0 }, - { "pipex", "Search for tag pipex", CMPL0 NULL, 0 }, - { "port", "Search for tag port", CMPL0 NULL, 0 }, - { "privileged", "Search for tag privileged", CMPL0 NULL, 0 }, - { "protected", "Search for tag protected", CMPL0 NULL, 0 }, - { "quit", "Search for tag quit", CMPL0 NULL, 0 }, - { "rad", "Search for tag rad", CMPL0 NULL, 0 }, - { "rdomain", "Search for tag rdomain", CMPL0 NULL, 0 }, - { "reboot", "Search for tag reboot", CMPL0 NULL, 0 }, - { "relay", "Search for tag relay", CMPL0 NULL, 0 }, - { "relayd", "Search for tag relayd", CMPL0 NULL, 0 }, - { "resolv", "Search for tag resolv", CMPL0 NULL, 0 }, - { "resolv.conf", "Search for tag resolv.conf", CMPL0 NULL, 0 }, - { "rip", "Search for tag rip", CMPL0 NULL, 0 }, - { "ripd", "Search for tag ripd", CMPL0 NULL, 0 }, - { "route", "Search for tag route", CMPL0 NULL, 0 }, - { "route6", "Search for tag route6", CMPL0 NULL, 0 }, - { "rtable", "Search for tag rtable", CMPL0 NULL, 0 }, - { "sa", "Search for tag sa", CMPL0 NULL, 0 }, - { "sadb", "Search for tag sadb", CMPL0 NULL, 0 }, - { "sasync", "Search for tag sasync", CMPL0 NULL, 0 }, - { "sasyncd", "Search for tag sasyncd", CMPL0 NULL, 0 }, - { "scheduler", "Search for tag scheduler", CMPL0 NULL, 0 }, - { "sensor", "Search for tag sensor", CMPL0 NULL, 0 }, - { "setenv", "Search for tag setenv", CMPL0 NULL, 0 }, - { "sh", "Search for tag sh", CMPL0 NULL, 0 }, - { "shell", "Search for tag shell", CMPL0 NULL, 0 }, - { "show", "Search for tag show", CMPL0 NULL, 0 }, - { "smtp", "Search for tag smtp", CMPL0 NULL, 0 }, - { "smtpd", "Search for tag smtpd", CMPL0 NULL, 0 }, - { "sniff", "Search for tag sniff", CMPL0 NULL, 0 }, - { "snmp", "Search for tag snmp", CMPL0 NULL, 0 }, - { "snmpd", "Search for tag snmpd", CMPL0 NULL, 0 }, - { "span", "Search for tag span", CMPL0 NULL, 0 }, - { "ssh", "Search for tag ssh", CMPL0 NULL, 0 }, - { "sshd", "Search for tag sshd", CMPL0 NULL, 0 }, - { "switch", "Search for tag switch", CMPL0 NULL, 0 }, - { "switchport", "Search for tag switchport", CMPL0 NULL, 0 }, - { "sync", "Search for tag sync", CMPL0 NULL, 0 }, - { "syncdev", "Search for tag syncdev", CMPL0 NULL, 0 }, - { "tcp", "Search for tag tcp", CMPL0 NULL, 0 }, - { "telnet", "Search for tag telnet", CMPL0 NULL, 0 }, - { "tftp", "Search for tag tftp", CMPL0 NULL, 0 }, - { "tftp-proxy", "Search for tag tftp-proxy", CMPL0 NULL, 0 }, - { "tpmr", "Search for tag tpmr", CMPL0 NULL, 0 }, - { "traceroute", "Search for tag traceroute", CMPL0 NULL, 0 }, - { "traceroute6", "Search for tag traceroute6", CMPL0 NULL, 0 }, - { "unprivileged", "Search for tag unprivileged", CMPL0 NULL, 0 }, - { "unsetenv", "Search for tag setenv", CMPL0 NULL, 0 }, - { "veb", "Search for tag veb", CMPL0 NULL, 0 }, - { "verbose", "Search for tag verbose", CMPL0 NULL, 0 }, - { "vlan", "Search for tag vlan", CMPL0 NULL, 0 }, - { "vnetid", "Search for tag vnetid", CMPL0 NULL, 0 }, - { "vni", "Search for tag vni", CMPL0 NULL, 0 }, - { "vpls", "Search for tag vpls", CMPL0 NULL, 0 }, - { "vrrp", "Search for tag vrrp", CMPL0 NULL, 0 }, - { "vxlan", "Search for tag vxlan", CMPL0 NULL, 0 }, - { "wake", "Search for tag wake", CMPL0 NULL, 0 }, - { "wg", "Search for tag wg", CMPL0 NULL, 0 }, - { "wireguard", "Search for tag wireguard", CMPL0 NULL, 0 }, - { "wol", "Search for tag wol", CMPL0 NULL, 0 }, - { "write-config", "Search for tag write-config", CMPL0 NULL, 0 }, - { "", "Read entire manual", CMPL0 NULL, 0 }, - { NULL, NULL, NULL, NULL, 0 } }; /* blob - /dev/null blob + 2937190f2448d7c6d4b248aa4be41e9c01fe99f9 (mode 755) --- /dev/null +++ mantab.sh @@ -0,0 +1,10 @@ +#!/bin/sh +echo '#include ' +echo '#include ' +echo '#include "../externs.h"' +echo 'struct ghs mantab[] = {' +grep '^\.Tg' "$1" | sort | uniq | cut -d ' ' -f2 | sed -e \ + 's/\(.*\)/ { "\1", "Search for tag \1", CMPL0 NULL, 0 },/' +echo ' { "", "Read entire manual", CMPL0 NULL, 0 },' +echo ' { NULL, NULL, NULL, NULL, 0 }' +echo '};'