slitaz-base-files annotate 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
rev   line source
pankso@139 1
pankso@139 2 SYNOPSIS
pankso@139 3 . /lib/libtaz.sh
pankso@139 4 function
pankso@139 5
al@270 6
pankso@139 7 DESCRIPTION
pankso@139 8 LibTaz is the base SliTaz SHell library used by almost all tools and
paul@166 9 utilities. It provides common SHell script functions, parses the cmdline
pankso@164 10 options and store values in a variable. The output messages can be
paul@166 11 formatted for raw/text, gtk, html and by default they are formatted for
pankso@139 12 a standard terminal supporting colors. LibTaz is in the directory
pankso@139 13 /lib/libtaz.sh since it is used when /usr may not be mounted.
pankso@164 14
al@270 15
pankso@139 16 FUNCTIONS
al@221 17 _ <string> Short name for "eval_gettext string; echo"
al@221 18 _n <string> Short name for "eval_gettext string"
pankso@167 19 status Return command status [Done|Failed]
al@270 20 separator [<char>] Display a line separator
pankso@167 21 newline Echo a new line if gettext or echo -n is used
al@221 22 boldify <string> Use a bold font for term, html or GTK output
al@221 23 colorize NB <string> Colorize a string in term mode
pankso@171 24 indent NB [string] Indent text in term mode
al@221 25 emsg <string> Output mark up messages
pankso@167 26 check_root Check if user is logged as root
al@221 27 debug <string> Display a DEBUG message when --debug is used
pankso@167 28 confirm Read answer to confirm an action
al@221 29 log <string> Log activity, $activity must be set
al@221 30 optlist <lines> Prints two-column list (of options, or functions, etc.)
al@221 31 longline <string> Wrap words in long terminal message
pankso@139 32
al@270 33
pankso@139 34 OPTIONS
pankso@139 35 --output=[raw|gtk|html]
pankso@164 36 --activity=/path/files/activity
pankso@164 37
al@270 38
pankso@164 39 EXAMPLES
al@270 40 _ 'Hello, $USER!'
al@270 41 _ 'Hello, %s!' $USER
al@270 42
al@270 43 echo -n 'Removing...'; rm $file; status
al@270 44
al@270 45 separator
al@270 46 separator '*'
al@270 47
al@270 48 newline
al@270 49
al@270 50 boldify 'Bold text'
al@270 51
al@270 52 colorize 32 "Message"
al@270 53 myprogram --color=32
al@270 54
al@270 55 indent 32 "Message"
al@270 56
al@270 57 emsg "<b>bold</b> <c 31>red</c> separator<-> newline<n> <i 26>indent"
al@270 58
al@270 59 check_root
al@270 60
al@270 61 debug "A='$A'"
al@270 62
al@270 63 echo -n "The question"; confirm
al@270 64 confirm "The question (y/N)?"
al@270 65
al@270 66 activity='/var/log/my.log'
pankso@164 67 log "Message"
al@270 68
al@221 69 optlist "\
al@270 70 option1 Description1 (after one or any number of tab symbols)
al@270 71 -a option2 $(_ 'Description2')"
al@270 72
al@270 73 longline $(busybox --help)
al@270 74 longline "$(cat /usr/share/licenses/lgpl.txt)"
al@270 75
al@270 76
al@270 77 USAGE NOTES
al@270 78 SliTaz Base functions used from boot scripts to end user tools.
al@270 79 Use gettext and not echo for messages. Keep output suitable for GTK boxes
al@270 80 and Ncurses dialog. LibTaz should not depend on any configuration file.
al@270 81 No bloated code here, functions must be used by at least 3-4 tools.
al@270 82
pankso@139 83
paul@166 84 AUTHORS
al@221 85 Christophe Lincoln
al@221 86 Aleksej Bobylev
pankso@164 87