slitaz-base-files view doc/libtaz.txt @ rev 270

Small improvements. libtaz.sh: move notes from script to readme, re-organize and simplify code, different separators allowed; libtaz.txt: wrote few new examples.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Thu Apr 30 02:00:25 2015 +0300 (2015-04-30)
parents 259c174621c7
children 3f16616140ea
line source
2 SYNOPSIS
3 . /lib/libtaz.sh
4 function
7 DESCRIPTION
8 LibTaz is the base SliTaz SHell library used by almost all tools and
9 utilities. It provides common SHell script functions, parses the cmdline
10 options and store values in a variable. The output messages can be
11 formatted for raw/text, gtk, html and by default they are formatted for
12 a standard terminal supporting colors. LibTaz is in the directory
13 /lib/libtaz.sh since it is used when /usr may not be mounted.
16 FUNCTIONS
17 _ <string> Short name for "eval_gettext string; echo"
18 _n <string> Short name for "eval_gettext string"
19 status Return command status [Done|Failed]
20 separator [<char>] Display a line separator
21 newline Echo a new line if gettext or echo -n is used
22 boldify <string> Use a bold font for term, html or GTK output
23 colorize NB <string> Colorize a string in term mode
24 indent NB [string] Indent text in term mode
25 emsg <string> Output mark up messages
26 check_root Check if user is logged as root
27 debug <string> Display a DEBUG message when --debug is used
28 confirm Read answer to confirm an action
29 log <string> Log activity, $activity must be set
30 optlist <lines> Prints two-column list (of options, or functions, etc.)
31 longline <string> Wrap words in long terminal message
34 OPTIONS
35 --output=[raw|gtk|html]
36 --activity=/path/files/activity
39 EXAMPLES
40 _ 'Hello, $USER!'
41 _ 'Hello, %s!' $USER
43 echo -n 'Removing...'; rm $file; status
45 separator
46 separator '*'
48 newline
50 boldify 'Bold text'
52 colorize 32 "Message"
53 myprogram --color=32
55 indent 32 "Message"
57 emsg "<b>bold</b> <c 31>red</c> separator<-> newline<n> <i 26>indent"
59 check_root
61 debug "A='$A'"
63 echo -n "The question"; confirm
64 confirm "The question (y/N)?"
66 activity='/var/log/my.log'
67 log "Message"
69 optlist "\
70 option1 Description1 (after one or any number of tab symbols)
71 -a option2 $(_ 'Description2')"
73 longline $(busybox --help)
74 longline "$(cat /usr/share/licenses/lgpl.txt)"
77 USAGE NOTES
78 SliTaz Base functions used from boot scripts to end user tools.
79 Use gettext and not echo for messages. Keep output suitable for GTK boxes
80 and Ncurses dialog. LibTaz should not depend on any configuration file.
81 No bloated code here, functions must be used by at least 3-4 tools.
84 AUTHORS
85 Christophe Lincoln
86 Aleksej Bobylev