@@ -291,6 +291,45 @@ gh_toc_get_filename() {
291291 echo " ${1##*/ } "
292292}
293293
294+ show_version () {
295+ echo " $gh_toc_version "
296+ echo
297+ echo " os: ` uname -s` "
298+ echo " arch: ` uname -m` "
299+ echo " kernel: ` uname -r` "
300+ echo " shell: ` $SHELL --version` "
301+ echo
302+ for tool in curl wget grep awk sed; do
303+ printf " %-5s: " $tool
304+ if ` type $tool & > /dev/null` ; then
305+ echo ` $tool --version | head -n 1`
306+ else
307+ echo " not installed"
308+ fi
309+ done
310+ }
311+
312+ show_help () {
313+ local app_name=$( basename " $0 " )
314+ echo " GitHub TOC generator ($app_name ): $gh_toc_version "
315+ echo " "
316+ echo " Usage:"
317+ echo " $app_name [options] src [src] Create TOC for a README file (url or local path)"
318+ echo " $app_name - Create TOC for markdown from STDIN"
319+ echo " $app_name --help Show help"
320+ echo " $app_name --version Show version"
321+ echo " "
322+ echo " Options:"
323+ echo " --indent <NUM> Set indent size. Default: 3."
324+ echo " --insert Insert new TOC into original file. For local files only. Default: false."
325+ echo " See https://github.com/ekalinin/github-markdown-toc/issues/41 for details."
326+ echo " --no-backup Remove backup file. Set --insert as well. Defaul: false."
327+ echo " --hide-footer Do not write date & author of the last TOC update. Set --insert as well. Default: false."
328+ echo " --skip-header Hide entry of the topmost headlines. Default: false."
329+ echo " See https://github.com/ekalinin/github-markdown-toc/issues/125 for details."
330+ echo " "
331+ }
332+
294333#
295334# Options handlers
296335#
@@ -299,38 +338,12 @@ gh_toc_app() {
299338 local indent=3
300339
301340 if [ " $1 " = ' --help' ] || [ $# -eq 0 ] ; then
302- local app_name=$( basename " $0 " )
303- echo " GitHub TOC generator ($app_name ): $gh_toc_version "
304- echo " "
305- echo " Usage:"
306- echo " $app_name [options] src [src] Create TOC for a README file (url or local path)"
307- echo " $app_name - Create TOC for markdown from STDIN"
308- echo " $app_name --help Show help"
309- echo " $app_name --version Show version"
310- echo " "
311- echo " Options:"
312- echo " --indent <NUM> Set indent size. Default: 3."
313- echo " --insert Insert new TOC into original file. For local files only. Default: false."
314- echo " See https://github.com/ekalinin/github-markdown-toc/issues/41 for details."
315- echo " --no-backup Remove backup file. Set --insert as well. Defaul: false."
316- echo " --hide-footer Do not write date & author of the last TOC update. Set --insert as well. Default: false."
317- echo " --skip-header Hide entry of the topmost headlines. Default: false."
318- echo " See https://github.com/ekalinin/github-markdown-toc/issues/125 for details."
319- echo " "
341+ show_help
320342 return
321343 fi
322344
323345 if [ " $1 " = ' --version' ]; then
324- echo " $gh_toc_version "
325- echo
326- echo " os: ` lsb_release -d | cut -f 2` "
327- echo " kernel: ` cat /proc/version` "
328- echo " shell: ` $SHELL --version` "
329- echo
330- for tool in curl wget grep awk sed; do
331- printf " %-5s: " $tool
332- echo ` $tool --version | head -n 1`
333- done
346+ show_version
334347 return
335348 fi
336349
0 commit comments