|
@@ -28,6 +28,8 @@ usage() {
|
28
|
28
|
" format FMT: 'markdown', 'manpage' and" \
|
29
|
29
|
" 'pod' are supported" \
|
30
|
30
|
-o \
|
|
31
|
+ "-O, --object Treat MODULE as function or variable" \
|
|
32
|
+ " name and find respective module first." \
|
31
|
33
|
"-d, --debug Turn on debugging" \
|
32
|
34
|
"-a, --all Don't ignore hidden (starting with" \
|
33
|
35
|
" underscore) modules or objects" \
|
|
@@ -71,10 +73,22 @@ find_lesspipe() {
|
71
|
73
|
2>/dev/null
|
72
|
74
|
}
|
73
|
75
|
|
|
76
|
+find_by() {
|
|
77
|
+ #
|
|
78
|
+ # Find module by object type $1 and name $2
|
|
79
|
+ #
|
|
80
|
+ local name=$1
|
|
81
|
+ sfdoc -a -l \
|
|
82
|
+ | grep ":$name$" \
|
|
83
|
+ | cut -d: -f1 \
|
|
84
|
+ | grep .
|
|
85
|
+}
|
|
86
|
+
|
74
|
87
|
main() {
|
75
|
88
|
local action # what to do
|
76
|
89
|
local format # export format
|
77
|
90
|
local module # module name or path/to/module.sh
|
|
91
|
+ local mspec # module/function name or path/to/module.sh
|
78
|
92
|
local m # module helper var
|
79
|
93
|
local RealModuleName # name to override eg. if accessing via filename
|
80
|
94
|
local encoding # encoding
|
|
@@ -82,8 +96,10 @@ main() {
|
82
|
96
|
action=man
|
83
|
97
|
format=markdown
|
84
|
98
|
encoding=utf8
|
|
99
|
+ spectype=mod
|
85
|
100
|
#shellcheck disable=SC2034
|
86
|
101
|
while true; do case "$1" in
|
|
102
|
+ -O|--object) spectype=obj; shift ;;
|
87
|
103
|
-d|--debug) PRETTY_DEBUG=true; shift ;;
|
88
|
104
|
-a|--all) SFDOC_SHOW_HIDDEN=true; shift ;;
|
89
|
105
|
-I|--include) SHELLFU_PATH="$2:$SHELLFU_PATH"; shift 2 || usage ;;
|
|
@@ -100,15 +116,20 @@ main() {
|
100
|
116
|
-*) usage ;;
|
101
|
117
|
*) break ;;
|
102
|
118
|
esac done
|
103
|
|
- module="$1"; shift
|
|
119
|
+ mspec="$1"; shift
|
104
|
120
|
debug -v SHELLFU_INCLUDE SHELLFU_PATH SFDOC_SHOW_HIDDEN
|
105
|
121
|
debug -v action format module RealModuleName
|
106
|
|
- case $action:$module in
|
|
122
|
+ case $action:$mspec in
|
107
|
123
|
lsx:*|lsm:*|wch:*) true ;;
|
108
|
124
|
*:) usage ;;
|
109
|
125
|
esac
|
|
126
|
+ case $spectype in
|
|
127
|
+ obj) module=$(find_by "$mspec") \
|
|
128
|
+ || die "no module found with: $mspec" ;;
|
|
129
|
+ *) module=$mspec ;;
|
|
130
|
+ esac
|
110
|
131
|
case $action in
|
111
|
|
- lsm|wch) : ;;
|
|
132
|
+ lsm) : ;;
|
112
|
133
|
*) mpath=$(select_mfile "$module") || die ;;
|
113
|
134
|
esac
|
114
|
135
|
case $action in
|
|
@@ -159,7 +180,7 @@ main() {
|
159
|
180
|
fi
|
160
|
181
|
;;
|
161
|
182
|
wch)
|
162
|
|
- select_mfile "$module"
|
|
183
|
+ echo "$mpath"
|
163
|
184
|
;;
|
164
|
185
|
esac
|
165
|
186
|
}
|