Browse Source

Rename mkpretty to pretty

Ans its internal sub-modules to _pretty_*
Alois Mahdal 9 years ago
parent
commit
fe7da66353

+ 59
- 0
include/_pretty_color.sh View File

@@ -0,0 +1,59 @@
1
+#!/bin/bash
2
+
3
+ffoo import termcolors
4
+
5
+
6
+FFOO_PRETTY_COLOR_DEBUG=""
7
+FFOO_PRETTY_COLOR_DIE=""
8
+FFOO_PRETTY_COLOR_USAGE_IS=""
9
+FFOO_PRETTY_COLOR_THINK=""
10
+FFOO_PRETTY_COLOR_WARN=""
11
+FFOO_PRETTY_COLOR_OFF=""
12
+
13
+
14
+__ffoo__pretty_color__init() {
15
+    test -t 2 || return 0   # stderr is a pipe/file; refrain from colors
16
+    FFOO_PRETTY_COLOR_DEBUG="${FFOO_TERMCOLORS_LBLUE}"
17
+    FFOO_PRETTY_COLOR_DIE="${FFOO_TERMCOLORS_LRED}"
18
+    FFOO_PRETTY_COLOR_USAGE_IS="${FFOO_TERMCOLORS_YELLOW}"
19
+    FFOO_PRETTY_COLOR_THINK="${FFOO_TERMCOLORS_NONE}"
20
+    FFOO_PRETTY_COLOR_WARN="${FFOO_TERMCOLORS_LRED}"
21
+    FFOO_PRETTY_COLOR_OFF="${FFOO_TERMCOLORS_NONE}"
22
+}
23
+
24
+
25
+_pretty_debug() {
26
+    while IFS= read line;
27
+    do echo -ne "${FFOO_PRETTY_COLOR_DEBUG}debug:$caller:$FFOO_PRETTY_COLOR_OFF"
28
+       echo "$line"; done
29
+}
30
+
31
+
32
+_pretty_die() {
33
+    echo -ne "$FFOO_PRETTY_COLOR_DIE"
34
+    while IFS= read line;
35
+    do echo "$line"; done
36
+    echo -ne "$FFOO_PRETTY_COLOR_OFF"
37
+}
38
+
39
+
40
+_pretty_usage_is() {
41
+    echo -ne "$FFOO_PRETTY_COLOR_USAGE_IS"
42
+    while IFS= read line;
43
+    do echo -e "$line"; done
44
+    echo -ne "$FFOO_PRETTY_COLOR_OFF"
45
+}
46
+
47
+
48
+_pretty_think() {
49
+    while IFS= read line;
50
+    do echo "$line"; done
51
+}
52
+
53
+
54
+_pretty_warn() {
55
+    echo -ne "$FFOO_PRETTY_COLOR_WARN"
56
+    while IFS= read line;
57
+    do echo "$line"; done
58
+    echo -ne "$FFOO_PRETTY_COLOR_OFF"
59
+}

include/mkpretty_html.sh → include/_pretty_html.sh View File

@@ -1,31 +1,31 @@
1 1
 #!/bin/bash
2 2
 
3 3
 
4
-mkpretty_debug() {
4
+_pretty_debug() {
5 5
     while IFS= read line;
6 6
     do echo "<p class='debug'>$caller  $line</p>"; done
7 7
 }
8 8
 
9 9
 
10
-mkpretty_die() {
10
+_pretty_die() {
11 11
     while IFS= read line;
12 12
     do echo "<p class='die'>$line</p>"; done
13 13
 }
14 14
 
15 15
 
16
-mkpretty_usage_is() {
16
+_pretty_usage_is() {
17 17
     while IFS= read line;
18 18
     do echo "<p class='usage'>$line</p>"; done
19 19
 }
20 20
 
21 21
 
22
-mkpretty_think() {
22
+_pretty_think() {
23 23
     while IFS= read line;
24 24
     do echo "<p class='think'>$line</p>"; done
25 25
 }
26 26
 
27 27
 
28
-mkpretty_warn() {
28
+_pretty_warn() {
29 29
     while IFS= read line;
30 30
     do echo "<p class='warn'>$line</p>"; done
31 31
 }

include/mkpretty_plain.sh → include/_pretty_plain.sh View File

@@ -1,27 +1,27 @@
1 1
 #!/bin/bash
2 2
 
3 3
 
4
-mkpretty_debug() {
4
+_pretty_debug() {
5 5
     while IFS= read line;
6 6
     do echo "debug:$caller: $line"; done
7 7
 }
8 8
 
9
-mkpretty_die() {
9
+_pretty_die() {
10 10
     while IFS= read line;
11 11
     do echo "$line"; done
12 12
 }
13 13
 
14
-mkpretty_usage_is() {
14
+_pretty_usage_is() {
15 15
     while IFS= read line;
16 16
     do echo "$line"; done
17 17
 }
18 18
 
19
-mkpretty_think() {
19
+_pretty_think() {
20 20
     while IFS= read line;
21 21
     do echo "$line"; done
22 22
 }
23 23
 
24
-mkpretty_warn() {
24
+_pretty_warn() {
25 25
     while IFS= read line;
26 26
     do echo "$line"; done
27 27
 }

+ 2
- 2
include/core.sh View File

@@ -1,7 +1,7 @@
1 1
 #!/bin/bash
2 2
 
3 3
 ffoo import exits
4
-ffoo import mkpretty
4
+ffoo import pretty
5 5
 
6 6
 
7 7
 ##--------------------##
@@ -173,7 +173,7 @@ __echo() {
173 173
         -v|--vars)  src=vars;  shift; break ;;
174 174
         *)          src=args;         break ;;
175 175
     esac done
176
-    prettyfn=mkpretty_$frontend
176
+    prettyfn=_pretty_$frontend
177 177
     case $frontend in
178 178
         warn|debug|die|usage_is)    __echo_$src "$@" | $prettyfn >&2 ;;
179 179
         think)                      __echo_$src "$@" | $prettyfn     ;;

+ 0
- 27
include/mkpretty.sh View File

@@ -1,27 +0,0 @@
1
-#!/bin/bash
2
-
3
-#
4
-# Name of prerry-printer module
5
-#
6
-# Friendly name of module used for decorating output.  For
7
-# example, if the value is NAME, a mkpretty_NAME module must
8
-# exist and be importable.  Otherwise mkpretty will fall back
9
-# to plain, which is also the default value.
10
-#
11
-FFOO_MKPRETTY=${FFOO_MKPRETTY:-plain}
12
-
13
-
14
-__ffoo_mkpretty__init() {
15
-    #
16
-    # Import proper submodule
17
-    #
18
-    if ffoo try_import mkpretty_${FFOO_MKPRETTY};
19
-    then
20
-        ffoo import mkpretty_${FFOO_MKPRETTY}
21
-        return 0
22
-    else
23
-        warn "falling back to mkpretty_plain"
24
-        FFOO_MKPRETTY=plain
25
-        ffoo import mkpretty_${FFOO_MKPRETTY}
26
-    fi
27
-}

+ 0
- 59
include/mkpretty_color.sh View File

@@ -1,59 +0,0 @@
1
-#!/bin/bash
2
-
3
-ffoo import termcolors
4
-
5
-
6
-FFOO_MKPRETTY_COLOR_DEBUG=""
7
-FFOO_MKPRETTY_COLOR_DIE=""
8
-FFOO_MKPRETTY_COLOR_USAGE_IS=""
9
-FFOO_MKPRETTY_COLOR_THINK=""
10
-FFOO_MKPRETTY_COLOR_WARN=""
11
-FFOO_MKPRETTY_COLOR_OFF=""
12
-
13
-
14
-__ffoo_mkpretty_color__init() {
15
-    test -t 2 || return 0   # stderr is a pipe/file; refrain from colors
16
-    FFOO_MKPRETTY_COLOR_DEBUG="${FFOO_TERMCOLORS_LBLUE}"
17
-    FFOO_MKPRETTY_COLOR_DIE="${FFOO_TERMCOLORS_LRED}"
18
-    FFOO_MKPRETTY_COLOR_USAGE_IS="${FFOO_TERMCOLORS_YELLOW}"
19
-    FFOO_MKPRETTY_COLOR_THINK="${FFOO_TERMCOLORS_NONE}"
20
-    FFOO_MKPRETTY_COLOR_WARN="${FFOO_TERMCOLORS_LRED}"
21
-    FFOO_MKPRETTY_COLOR_OFF="${FFOO_TERMCOLORS_NONE}"
22
-}
23
-
24
-
25
-mkpretty_debug() {
26
-    while IFS= read line;
27
-    do echo -ne "${FFOO_MKPRETTY_COLOR_DEBUG}debug:$caller:$FFOO_MKPRETTY_COLOR_OFF"
28
-       echo "$line"; done
29
-}
30
-
31
-
32
-mkpretty_die() {
33
-    echo -ne "$FFOO_MKPRETTY_COLOR_DIE"
34
-    while IFS= read line;
35
-    do echo "$line"; done
36
-    echo -ne "$FFOO_MKPRETTY_COLOR_OFF"
37
-}
38
-
39
-
40
-mkpretty_usage_is() {
41
-    echo -ne "$FFOO_MKPRETTY_COLOR_USAGE_IS"
42
-    while IFS= read line;
43
-    do echo -e "$line"; done
44
-    echo -ne "$FFOO_MKPRETTY_COLOR_OFF"
45
-}
46
-
47
-
48
-mkpretty_think() {
49
-    while IFS= read line;
50
-    do echo "$line"; done
51
-}
52
-
53
-
54
-mkpretty_warn() {
55
-    echo -ne "$FFOO_MKPRETTY_COLOR_WARN"
56
-    while IFS= read line;
57
-    do echo "$line"; done
58
-    echo -ne "$FFOO_MKPRETTY_COLOR_OFF"
59
-}

+ 27
- 0
include/pretty.sh View File

@@ -0,0 +1,27 @@
1
+#!/bin/bash
2
+
3
+#
4
+# Name of prerry-printer module
5
+#
6
+# Friendly name of module used for decorating output.  For
7
+# example, if the value is NAME, a _pretty_NAME module must
8
+# exist and be importable.  Otherwise pretty will fall back
9
+# to plain, which is also the default value.
10
+#
11
+FFOO_PRETTY=${FFOO_PRETTY:-plain}
12
+
13
+
14
+__ffoo_pretty__init() {
15
+    #
16
+    # Import proper submodule
17
+    #
18
+    if ffoo try_import _pretty_${FFOO_PRETTY};
19
+    then
20
+        ffoo import _pretty_${FFOO_PRETTY}
21
+        return 0
22
+    else
23
+        warn "falling back to _pretty_plain"
24
+        FFOO_PRETTY=plain
25
+        ffoo import _pretty_${FFOO_PRETTY}
26
+    fi
27
+}

+ 4
- 6
notes/TODO.md View File

@@ -53,15 +53,13 @@ core.sh
53 53
 -------
54 54
 
55 55
 *   add -name arg to debug, e.g. for pipe/cmd/file and use it in
56
-    mkpretty
56
+    pretty
57 57
 
58
-*   set fixed list of valid "leaks" to mkpretty
58
+*   set fixed list of valid "leaks" to pretty
59 59
 
60 60
 
61
-mkpretty_*.sh
62
--------------
63
-
64
-*   change name to pretty
61
+_pretty_*.sh
62
+------------
65 63
 
66 64
 *   implement options (like `ps -o`, et al.)
67 65
 

+ 4
- 4
notes/packaging.md View File

@@ -38,10 +38,10 @@ No modules, just ffoo.sh and supporting binaries.
38 38
 
39 39
  *  core
40 40
  *  error
41
- *  mkpretty
42
- *  mkpretty_color
43
- *  mkpretty_html
44
- *  mkpretty_plain
41
+ *  pretty
42
+ *  _pretty_color
43
+ *  _pretty_html
44
+ *  _pretty_plain
45 45
  *  types
46 46
 
47 47
 

+ 17
- 17
test/data/ffoo_api/functions.oracle.stdout View File

@@ -1,3 +1,19 @@
1
+_pretty_color.__ffoo__pretty_color__init
2
+_pretty_color._pretty_debug
3
+_pretty_color._pretty_die
4
+_pretty_color._pretty_think
5
+_pretty_color._pretty_usage_is
6
+_pretty_color._pretty_warn
7
+_pretty_html._pretty_debug
8
+_pretty_html._pretty_die
9
+_pretty_html._pretty_think
10
+_pretty_html._pretty_usage_is
11
+_pretty_html._pretty_warn
12
+_pretty_plain._pretty_debug
13
+_pretty_plain._pretty_die
14
+_pretty_plain._pretty_think
15
+_pretty_plain._pretty_usage_is
16
+_pretty_plain._pretty_warn
1 17
 charmenu.charmenu
2 18
 config.__cfgrep__cat
3 19
 config.__cfgrep__fltcmt
@@ -42,23 +58,7 @@ misc.expand_tilde
42 58
 misc.filter
43 59
 misc.mute_known
44 60
 misc.select_args
45
-mkpretty.__ffoo_mkpretty__init
46
-mkpretty_color.__ffoo_mkpretty_color__init
47
-mkpretty_color.mkpretty_debug
48
-mkpretty_color.mkpretty_die
49
-mkpretty_color.mkpretty_think
50
-mkpretty_color.mkpretty_usage_is
51
-mkpretty_color.mkpretty_warn
52
-mkpretty_html.mkpretty_debug
53
-mkpretty_html.mkpretty_die
54
-mkpretty_html.mkpretty_think
55
-mkpretty_html.mkpretty_usage_is
56
-mkpretty_html.mkpretty_warn
57
-mkpretty_plain.mkpretty_debug
58
-mkpretty_plain.mkpretty_die
59
-mkpretty_plain.mkpretty_think
60
-mkpretty_plain.mkpretty_usage_is
61
-mkpretty_plain.mkpretty_warn
61
+pretty.__ffoo_pretty__init
62 62
 recon.age_of_leaf
63 63
 recon.age_of_tree
64 64
 recon.cat_uri

+ 4
- 4
test/data/ffoo_api/modules.oracle.stdout View File

@@ -1,12 +1,12 @@
1
+_pretty_color
2
+_pretty_html
3
+_pretty_plain
1 4
 charmenu
2 5
 config
3 6
 core
4 7
 exits
5 8
 misc
6
-mkpretty
7
-mkpretty_color
8
-mkpretty_html
9
-mkpretty_plain
9
+pretty
10 10
 recon
11 11
 stats
12 12
 termcolors