소스 검색

Add 'forcecolor' module

Same as 'color' but does not turn off the colors on non-terminal tty.
Alois Mahdal 5 년 전
부모
커밋
db7e27520b

+ 1
- 0
packaging/debian/shellfu-bash-pretty.install 파일 보기

1
 /usr/share/shellfu/include-bash/_pretty_color.sh
1
 /usr/share/shellfu/include-bash/_pretty_color.sh
2
+/usr/share/shellfu/include-bash/_pretty_forcecolor.sh
2
 /usr/share/shellfu/include-bash/_pretty_html.sh
3
 /usr/share/shellfu/include-bash/_pretty_html.sh
3
 /usr/share/shellfu/include-bash/_pretty_journald.sh
4
 /usr/share/shellfu/include-bash/_pretty_journald.sh
4
 /usr/share/shellfu/include-bash/_pretty_notify.sh
5
 /usr/share/shellfu/include-bash/_pretty_notify.sh

+ 1
- 0
packaging/template.spec 파일 보기

175
 
175
 
176
 %files bash-pretty
176
 %files bash-pretty
177
 %{_datadir}/%{name}/include-bash/_pretty_color.sh
177
 %{_datadir}/%{name}/include-bash/_pretty_color.sh
178
+%{_datadir}/%{name}/include-bash/_pretty_forcecolor.sh
178
 %{_datadir}/%{name}/include-bash/_pretty_html.sh
179
 %{_datadir}/%{name}/include-bash/_pretty_html.sh
179
 %{_datadir}/%{name}/include-bash/_pretty_journald.sh
180
 %{_datadir}/%{name}/include-bash/_pretty_journald.sh
180
 %{_datadir}/%{name}/include-bash/_pretty_notify.sh
181
 %{_datadir}/%{name}/include-bash/_pretty_notify.sh

+ 62
- 0
src/include-bash/_pretty_forcecolor.sh 파일 보기

1
+#!/bin/bash
2
+
3
+shellfu import termcolors
4
+
5
+
6
+_PRETTY_FORCECOLOR_DEBUG="${TERMCOLORS_LBLUE}"
7
+_PRETTY_FORCECOLOR_DIE="${TERMCOLORS_LRED}"
8
+_PRETTY_FORCECOLOR_USAGE_IS="${TERMCOLORS_YELLOW}"
9
+_PRETTY_FORCECOLOR_THINK="${TERMCOLORS_LBLACK}"
10
+_PRETTY_FORCECOLOR_WARN="${TERMCOLORS_LRED}"
11
+_PRETTY_FORCECOLOR_OFF="${TERMCOLORS_NONE}"
12
+
13
+
14
+_pretty__debug() {
15
+    local decor="()"
16
+    local caller_is_main=${caller_is_main:-false}
17
+    local caller=${caller:-UNKNOWN}
18
+    $caller_is_main && decor=
19
+    while IFS= read -r line;
20
+    do echo -ne "${_PRETTY_FORCECOLOR_DEBUG}debug:$caller$decor:$_PRETTY_FORCECOLOR_OFF"
21
+       echo "$line"; done
22
+}
23
+
24
+
25
+_pretty__die() {
26
+    echo -ne "$_PRETTY_FORCECOLOR_DIE"
27
+    while IFS= read -r line;
28
+    do echo "$line"; done
29
+    echo -ne "$_PRETTY_FORCECOLOR_OFF"
30
+}
31
+
32
+
33
+_pretty__mkhelp() {
34
+    echo -ne "$_PRETTY_FORCECOLOR_USAGE_IS"
35
+    while IFS= read -r line;
36
+    do echo -e "$line"; done
37
+    echo -ne "$_PRETTY_FORCECOLOR_OFF"
38
+}
39
+
40
+
41
+_pretty__mkusage() {
42
+    echo -ne "$_PRETTY_FORCECOLOR_USAGE_IS"
43
+    while IFS= read -r line;
44
+    do echo -e "$line"; done
45
+    echo -ne "$_PRETTY_FORCECOLOR_OFF"
46
+}
47
+
48
+
49
+_pretty__think() {
50
+    echo -ne "$_PRETTY_FORCECOLOR_THINK"
51
+    while IFS= read -r line;
52
+    do echo "$line"; done
53
+    echo -ne "$_PRETTY_FORCECOLOR_OFF"
54
+}
55
+
56
+
57
+_pretty__warn() {
58
+    echo -ne "$_PRETTY_FORCECOLOR_WARN"
59
+    while IFS= read -r line;
60
+    do echo "$line"; done
61
+    echo -ne "$_PRETTY_FORCECOLOR_OFF"
62
+}

+ 1
- 0
tests/shellfu_api/TF_RUN 파일 보기

12
         -e _pretty_journald \
12
         -e _pretty_journald \
13
         -e _pretty_html \
13
         -e _pretty_html \
14
         -e sync \
14
         -e sync \
15
+        -e _pretty_forcecolor \
15
         -e _pretty_color \
16
         -e _pretty_color \
16
         -e inigrep \
17
         -e inigrep \
17
         -e _pretty_notify \
18
         -e _pretty_notify \

+ 6
- 0
tests/shellfu_api/oracle/functions.stdout 파일 보기

5
 _pretty_color:_pretty__mkusage
5
 _pretty_color:_pretty__mkusage
6
 _pretty_color:_pretty__think
6
 _pretty_color:_pretty__think
7
 _pretty_color:_pretty__warn
7
 _pretty_color:_pretty__warn
8
+_pretty_forcecolor:_pretty__debug
9
+_pretty_forcecolor:_pretty__die
10
+_pretty_forcecolor:_pretty__mkhelp
11
+_pretty_forcecolor:_pretty__mkusage
12
+_pretty_forcecolor:_pretty__think
13
+_pretty_forcecolor:_pretty__warn
8
 _pretty_html:_pretty__debug
14
 _pretty_html:_pretty__debug
9
 _pretty_html:_pretty__die
15
 _pretty_html:_pretty__die
10
 _pretty_html:_pretty__mkhelp
16
 _pretty_html:_pretty__mkhelp

+ 1
- 0
tests/shellfu_api/oracle/modules.stdout 파일 보기

1
 _pretty_color
1
 _pretty_color
2
+_pretty_forcecolor
2
 _pretty_html
3
 _pretty_html
3
 _pretty_journald
4
 _pretty_journald
4
 _pretty_notify
5
 _pretty_notify

+ 6
- 0
tests/shellfu_api/oracle/variables.stdout 파일 보기

4
 _pretty_color:_PRETTY_COLOR_THINK
4
 _pretty_color:_PRETTY_COLOR_THINK
5
 _pretty_color:_PRETTY_COLOR_USAGE_IS
5
 _pretty_color:_PRETTY_COLOR_USAGE_IS
6
 _pretty_color:_PRETTY_COLOR_WARN
6
 _pretty_color:_PRETTY_COLOR_WARN
7
+_pretty_forcecolor:_PRETTY_FORCECOLOR_DEBUG
8
+_pretty_forcecolor:_PRETTY_FORCECOLOR_DIE
9
+_pretty_forcecolor:_PRETTY_FORCECOLOR_OFF
10
+_pretty_forcecolor:_PRETTY_FORCECOLOR_THINK
11
+_pretty_forcecolor:_PRETTY_FORCECOLOR_USAGE_IS
12
+_pretty_forcecolor:_PRETTY_FORCECOLOR_WARN
7
 charmenu:CHARMENU_FILE
13
 charmenu:CHARMENU_FILE
8
 exit:EXIT_ERROR
14
 exit:EXIT_ERROR
9
 exit:EXIT_NO
15
 exit:EXIT_NO