slitaz-base-files annotate doc/libtaz.txt @ rev 343

fix ipinfo
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Oct 04 14:28:55 2020 +0000 (2020-10-04)
parents 5829aa52b9ee
children
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
al@317 28 die <string> Report error and finish work
paul@325 29 im Returns true if you're in interactive mode
pankso@167 30 confirm Read answer to confirm an action
al@221 31 log <string> Log activity, $activity must be set
al@221 32 optlist <lines> Prints two-column list (of options, or functions, etc.)
al@221 33 longline <string> Wrap words in long terminal message
al@271 34 title <string> Print localized title
al@271 35 footer [<string>] Print footer
al@271 36 action <string> Print action
al@271 37 itemize <string> Print long line as list item (check for :-* markers)
pankso@139 38
al@270 39
pankso@139 40 OPTIONS
pankso@139 41 --output=[raw|gtk|html]
pankso@164 42 --activity=/path/files/activity
al@289 43 --quiet Display nothing but errors (usually: action ... status)
al@289 44 --cols=<number> Output width in columns
pankso@164 45
al@270 46
pankso@164 47 EXAMPLES
al@270 48 _ 'Hello, $USER!'
al@270 49 _ 'Hello, %s!' $USER
al@270 50
al@270 51 echo -n 'Removing...'; rm $file; status
al@270 52
al@270 53 separator
al@270 54 separator '*'
al@270 55
al@270 56 newline
al@270 57
al@270 58 boldify 'Bold text'
al@270 59
al@270 60 colorize 32 "Message"
al@270 61 myprogram --color=32
al@270 62
al@270 63 indent 32 "Message"
al@270 64
al@270 65 emsg "<b>bold</b> <c 31>red</c> separator<-> newline<n> <i 26>indent"
al@270 66
al@270 67 check_root
al@270 68
al@270 69 debug "A='$A'"
al@270 70
al@317 71 die 'Config %s absent. Exit' $config
al@317 72
al@317 73
al@317 74 Using confirm()
al@317 75 Use global options for auto-answering: '--yes' or '--noconfirm'.
al@317 76 Use global option '--timeout' to define the wait time (default is 30 s).
al@317 77 The letters "y", "Y", "n" and "N", used in the response, are localized.
al@317 78 1. Outdated syntax. No options. Displays translated " [y/N] ? " and waits
al@317 79 for your input.
al@317 80 Answer formula is "[y/N]": to answer "yes" you need to enter "y" (or "Y"),
al@317 81 while to answer "no" you may enter "n" or "N" or any other letter, or
al@317 82 even just press Enter.
al@317 83
al@317 84 echo -n "The question"; confirm && echo "Confirmed"
al@317 85
al@317 86 2. New syntax. Option is the string displayed. Answer formula the same.
al@317 87
al@317 88 confirm "The question [y/N]?" && echo "Confirmed"
al@317 89
al@317 90 3. Modern syntax. Two options: the question and the preferred answer.
al@317 91 Displays the question and then translated answer formula as "[Y/n]" or
al@317 92 "[y/N]" depending on the preferred answer.
al@317 93
al@317 94 confirm "The question?" y && echo "Confirmed"
al@317 95
al@317 96 In all cases, it returns "true" if you answer "yes", while returns "false"
al@317 97 otherwise.
al@317 98
al@270 99
al@270 100 activity='/var/log/my.log'
pankso@164 101 log "Message"
al@270 102
al@221 103 optlist "\
al@270 104 option1 Description1 (after one or any number of tab symbols)
al@270 105 -a option2 $(_ 'Description2')"
al@270 106
al@270 107 longline $(busybox --help)
al@270 108 longline "$(cat /usr/share/licenses/lgpl.txt)"
al@270 109
al@271 110 title "Summary"
al@271 111 footer "$(_ 'No errors found')"
al@271 112 action 'Checking settings...'; checking_settings; status
al@271 113
al@271 114 itemize " - Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed d\
al@271 115 o eiusmod tempor incididunt ut labore et dolore magna aliqua."
al@271 116 itemize " * Ut enim ad minim veniam, quis nostrud exercitation ullamco lab\
al@271 117 oris nisi ut aliquip ex ea commodo consequat."
al@271 118
al@270 119
al@270 120 USAGE NOTES
al@270 121 SliTaz Base functions used from boot scripts to end user tools.
al@270 122 Use gettext and not echo for messages. Keep output suitable for GTK boxes
al@270 123 and Ncurses dialog. LibTaz should not depend on any configuration file.
al@270 124 No bloated code here, functions must be used by at least 3-4 tools.
al@270 125
pankso@139 126
paul@166 127 AUTHORS
al@221 128 Christophe Lincoln
al@221 129 Aleksej Bobylev
pankso@164 130