aboutsummaryrefslogtreecommitdiff
blob: 787940812b874a638aed39c52c67c4895c3f1c0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash

# Copyright (c) 2005 Gentoo Foundation.
# $Header$
# This file is part of the 'Eclectic' tools framework.
#
# Eclectic is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
#
# Eclectic is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along with
# Eclectic; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA  02111-1307  USA

# write_error_msg PUBLIC
# write an error
write_error_msg() {
    echo -e "${COLOUR_ERROR}!!! Error: ${COLOUR_NORMAL}${*}" 1>&2
}

# write_list_start PUBLIC
# Write a list heading
write_list_start() {
    echo -e "${COLOUR_LIST_HEADER}${*}${COLOUR_NORMAL}"
}

# write_kv_list_entry PUBLIC
# Write a key/value list entry with $1 on the left and $2 on the right
write_kv_list_entry() {
    local n
    echo -n -e "  ${COLOUR_LIST_LEFT}${1}${COLOUR_NORMAL} "
    for (( n = 1 ; n <= $(( 25 - ${#1} )) ; ++n )) ; do
        echo -n " "
    done
    echo -e "${COLOUR_LIST_RIGHT}${2}${COLOUR_NORMAL}"
}

# write_numbered_list_entry PUBLIC
# Write out a numbered list entry with index $1 and text $2
write_numbered_list_entry() {
    local n
    echo -n -e "  ${COLOUR_LIST_LEFT}[${1}]${COLOUR_NORMAL}"
    for (( n = 1 ; n <= $(( 4 - ${#1} )) ; ++n )) ; do
        echo -n " "
    done
    echo -e "${COLOUR_LIST_RIGHT}${2}${COLOUR_NORMAL}"
}

# write_numbered_list PUBLIC
# Write out a numbered list
write_numbered_list() {
    local n=1
    while [[ ${#@} -gt 0 ]] ; do
        item=${1}
        shift
        write_numbered_list_entry "${n}" "${item}"
        n=$((  ${n} + 1 ))
    done
}

# space PUBLIC
# Write $1 numbers of spaces
space() {
    local n=${1}
    while [[ ${n} -gt 0 ]] ; do
        echo -ne " "
        n=$(( ${n} - 1))
    done
}

# vim: set sw=4 et sts=4 tw=80 :