summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/includes
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2013-11-20 21:05:33 +0000
committerdteske <dteske@FreeBSD.org>2013-11-20 21:05:33 +0000
commit05ae219f7613ae5548d156120d2c08f12beac31e (patch)
tree8abe504bfe14e3e7eb926126ae672bff479528c6 /usr.sbin/bsdconfig/includes
parentf30f059959fc442e1f0071de4ad62f34e8a6f631 (diff)
downloadFreeBSD-src-05ae219f7613ae5548d156120d2c08f12beac31e.zip
FreeBSD-src-05ae219f7613ae5548d156120d2c08f12beac31e.tar.gz
Add a `-d' flag for printing the description of each function.
Diffstat (limited to 'usr.sbin/bsdconfig/includes')
-rw-r--r--usr.sbin/bsdconfig/includes/USAGE5
-rwxr-xr-xusr.sbin/bsdconfig/includes/includes31
2 files changed, 28 insertions, 8 deletions
diff --git a/usr.sbin/bsdconfig/includes/USAGE b/usr.sbin/bsdconfig/includes/USAGE
index 48dead2..aaee35a 100644
--- a/usr.sbin/bsdconfig/includes/USAGE
+++ b/usr.sbin/bsdconfig/includes/USAGE
@@ -28,6 +28,7 @@ Usage: bsdconfig @PROGRAM_NAME@ [OPTIONS] [include ...]
OPTIONS:
-a Always use color even when output is not to a terminal.
+ -d Print the description for each function selected.
-f Show functions for selected includes.
-F pattern
If `-f', only print functions matching pattern. Without `-f'
@@ -64,3 +65,7 @@ EXAMPLES:
bsdconfig @PROGRAM_NAME@ -F show common
NB: The `.subr' suffix on the end of the include is optional.
+
+ Show descriptions of each of the `show' functions:
+
+ bsdconfig @PROGRAM_NAME@ -dfF show
diff --git a/usr.sbin/bsdconfig/includes/includes b/usr.sbin/bsdconfig/includes/includes
index cfbfb98..2e7bc08 100755
--- a/usr.sbin/bsdconfig/includes/includes
+++ b/usr.sbin/bsdconfig/includes/includes
@@ -29,7 +29,7 @@
############################################################ INCLUDES
# Prevent common.subr from auto initializing debugging (this is not an inter-
-# active utility that requires debugging).
+# active utility that requires debugging; also `-d' has been repurposed).
#
DEBUG_SELF_INITIALIZE=NO
@@ -50,6 +50,7 @@ ipgm=$( f_index_menusel_keyword $BSDCFG_LIBE/$APP_DIR/INDEX "$pgm" )
# Options
#
USE_COLOR=1
+SHOW_DESC=
SHOW_FUNCS=
FUNC_PATTERN=
@@ -64,20 +65,33 @@ show_include()
local file="${1#./}"
local pattern="${FUNC_PATTERN:-.*}"
- output=$( awk -v use_color=${USE_COLOR:-0} -v re="$pattern" '
+ output=$( awk \
+ -v use_color=${USE_COLOR:-0} \
+ -v re="$pattern" \
+ -v show_desc=${SHOW_DESC:-0} '
/^$/,/^#/ {
if ($0 ~ /^# f_/) {
if (!match($2, re)) next
if (use_color)
- printf " %s%s%s\n",
+ printf "+%s%s%s\n",
substr($0, 2, RSTART),
substr($0, 2 + RSTART, RLENGTH),
substr($0, 2 + RSTART + RLENGTH)
else
print substr($0, 2)
- print_more = substr($0, length($0)) == "\\"
+ if (show_desc)
+ print_more = 1
+ else
+ print_more = substr($0, length($0)) == "\\"
}
- while (print_more) {
+ if (show_desc && print_more) {
+ getline
+ while ($0 ~ /^#/) {
+ print substr($0, 2)
+ getline
+ }
+ print_more = 0
+ } else while (print_more) {
getline
print substr($0, 2)
print_more = substr($0, length($0)) == "\\"
@@ -89,10 +103,10 @@ show_include()
return $SUCCESS
fi
if [ "$FUNC_PATTERN" ]; then
- printf "$msg_functions_in_matching\n" \
+ printf ">>> $msg_functions_in_matching\n" \
"$file" "$FUNC_PATTERN"
else
- printf "$msg_functions_in\n" "$file"
+ printf ">>> $msg_functions_in\n" "$file"
fi
echo "$output"
echo # blank line to simplify awk(1)-based reparse
@@ -110,9 +124,10 @@ show_include()
#
# Process command-line arguments
#
-while getopts afF:hn flag; do
+while getopts adfF:hn flag; do
case "$flag" in
a) USE_COLOR=1 ;;
+ d) SHOW_DESC=1 ;;
f) SHOW_FUNCS=1 ;;
F) FUNC_PATTERN="$OPTARG" ;;
n) USE_COLOR= ;;
OpenPOWER on IntegriCloud