tazpkg view modules/tazpkg-help @ rev 811
Update documentation (attempt to describe all the commands both with all options). Strongly need to review and update translations and docs! Add TazPkg help system for commandline (based on the HTML docs). Attempt to drop all package lists but "packages.info". Small improvements and code prettify.
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Thu Jun 04 00:15:13 2015 +0300 (2015-06-04) |
parents | |
children |
line source
1 #!/bin/sh
2 # TazPkg - Tiny autonomous zone packages manager.
3 # TazPkg help system
5 . /lib/libtaz.sh
7 T="${1#-}"
8 DOC='/usr/share/doc/tazpkg/tazpkg.html'
9 QUERY="$T"
11 if [ -z "$T" ]; then
12 tazpkg usage; exit 0
13 fi
15 commands="\
16 :usage::help,h::activity,log,a::clean-cache,cc::shell::list,l::list-mirror,lm:\
17 :list-config::search,s::search-pkgname,sp::search-file,sf::get,g::install,i:\
18 :get-install,gi::install-list,get-install-list::remove,r::reconfigure::link:\
19 :set-release::add-flavor,install-flavor::info::desc,d::list-files,lf:\
20 :block,b,unblock,u,chblock::check::bugs::depends,rdepends::extract,e::pack:\
21 :repack::repack-config::recompress::convert,c::list-suggested::recharge:
22 :upgrade,up::setup-mirror,sm::add-undigest,setup-undigest::list-undigest:\
23 :remove-undigest:"
25 if [ ! $(echo $commands | grep -e "[:,]$T[:,]") ]; then
26 try1=$(echo $commands | grep -oe ":[^:]*$T[^:]*:")
27 if [ -z "$try1" ]; then
28 _ 'Sorry, no help for "%s"' "$QUERY"; newline; exit 0
29 fi
31 try2=$(echo "$try1" | tr -d : )
33 trynum=$(echo "$try2" | wc -l)
34 if [ "$trynum" -ne 1 ]; then
35 _p '%d help topic available:' '%d help topics available:' "$trynum" \
36 "$trynum"; newline
37 echo "$try2" | sed 's|^| * &|; s| ,| |; s|,|, |g'
38 exit 0
39 else
40 T="${try2%%,*}"
41 fi
42 else
43 try3=$(echo $commands | grep -oe "[:,]$T[:,]")
44 case $try3 in
45 :*) try4="$try3";;
46 ,*) try4=$(echo $commands | grep -oe ":[^:]*$try3" | cut -d, -f1);;
47 esac
49 T=$(echo $try4 | tr -d ':,')
50 fi
52 title=$(echo $commands | grep -oe ":$T\(,[^:]*\)*:" | tr -d : | sed 's|,|, |g')
55 # style: <h3 id="TOPIC">
56 HLP=$(sed "/id=\"$T\"/,/<h3/!d; /<h3/d; /<\/h3/d; /<h2/,\$d" $DOC)
57 if [ -z "$HLP" ]; then
58 # style: <a name="TOPIC"></a>
59 HLP=$(sed "/name=\"$T\"/,/name=/!d; /name=/d; /<h3/d; /<h2/,\$d" $DOC)
60 fi
62 if [ -z "$HLP" ]; then
63 _ 'Sorry, no help for "%s"' "$QUERY"
64 exit 0
65 fi
67 PRE=$(echo "$HLP" | sed "/^$/d; /<pre>/,/<\/pre\>/{s|.*| &|; s| |·|g}; \
68 s|^ </*pre>$||; s|<pre>||; s|</pre>||; s| ·#| #|;" | tr '\n' ' ' | \
69 sed '/^[ ]*$/d' | \
70 sed 's|[ ][ ]*| |g;' | \
71 sed 's|[ ]*<dl>|O\n|g; s|[ ]*</dl>|L\n|g; s|[ ]*</*dt>||g;' | \
72 sed 's|[ ]*<dd>| |g; s|</dd>|\n|g;' | \
73 sed 's|<h4>|<b>|g; s|</h4>|</b>\n|g' | \
74 sed 's|[ ]*<p>[ ]*||g; s|[ ]*</p>|\n \n|g; s| |\n |g' | \
75 sed 's|<a [^>]*>||g; s|</a>||g; s|·| |g' | \
76 sed 's|</*nobr>||g; s|­||g; s|^[ ]*||' | \
77 sed '/^$/d' | \
78 sed 's|<tt>|A|g; s|<code>|A|g; s|<em>|B|g; s|<strong>|B|g; \
79 s|</tt>|D|g; s|</code>|D|g; s|</em>|D|g; s|</strong>|C|g; \
80 s|DD|D|g;')
82 OPT=$(echo "$PRE" | sed '/O/,/L/!d; /[OL]/d')
83 OPTLIST=$(optlist "$OPT")
85 OPT0=$(echo "$PRE" | tr '\n' '@')
86 OPTA=$(echo "$OPT" | tr '\n' '@')
87 OPTB=$(echo "$OPTLIST" | tr '\n' '@')
89 PRE2=$(echo "$OPT0" | sed "s|$OPTA|$OPTB|" | tr '@' '\n' | sed '/O/d; s|L||')
91 [ ! -z "$TA" ] && T="$T, $TA"
93 title '$title'
94 emsg "$(longline "$PRE2" | sed 's|A|<c 33>|g; s|B|<c 36>|g; s|C|<b>|g; s|D|</c>|g; ')"
95 newline