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

libtaz.sh: add _p(), title(), footer(), action(), itemize(); update doc/libtaz.sh and testsuite.sh
author Aleksej Bobylev <al.bobylev@gmail.com>
date Mon May 25 19:32:59 2015 +0300 (2015-05-25)
parents 29f028ec8077
children cca198d5952c
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
32 title <string> Print localized title
33 footer [<string>] Print footer
34 action <string> Print action
35 itemize <string> Print long line as list item (check for :-* markers)
38 OPTIONS
39 --output=[raw|gtk|html]
40 --activity=/path/files/activity
43 EXAMPLES
44 _ 'Hello, $USER!'
45 _ 'Hello, %s!' $USER
47 echo -n 'Removing...'; rm $file; status
49 separator
50 separator '*'
52 newline
54 boldify 'Bold text'
56 colorize 32 "Message"
57 myprogram --color=32
59 indent 32 "Message"
61 emsg "<b>bold</b> <c 31>red</c> separator<-> newline<n> <i 26>indent"
63 check_root
65 debug "A='$A'"
67 echo -n "The question"; confirm
68 confirm "The question (y/N)?"
70 activity='/var/log/my.log'
71 log "Message"
73 optlist "\
74 option1 Description1 (after one or any number of tab symbols)
75 -a option2 $(_ 'Description2')"
77 longline $(busybox --help)
78 longline "$(cat /usr/share/licenses/lgpl.txt)"
80 title "Summary"
81 footer "$(_ 'No errors found')"
82 action 'Checking settings...'; checking_settings; status
84 itemize " - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed d\
85 o eiusmod tempor incididunt ut labore et dolore magna aliqua."
86 itemize " * Ut enim ad minim veniam, quis nostrud exercitation ullamco lab\
87 oris nisi ut aliquip ex ea commodo consequat."
90 USAGE NOTES
91 SliTaz Base functions used from boot scripts to end user tools.
92 Use gettext and not echo for messages. Keep output suitable for GTK boxes
93 and Ncurses dialog. LibTaz should not depend on any configuration file.
94 No bloated code here, functions must be used by at least 3-4 tools.
97 AUTHORS
98 Christophe Lincoln
99 Aleksej Bobylev