Browse Source

Add greeter with exposed module

Split saturnin-demo to a double-package distribution, where one package
provides core saturnin-demo with its subcommands and the other provides
a Shellfu/Bash module saturnin_demo_greet.sh used by the first one.
Alois Mahdal 7 years ago
parent
commit
6c1727fab5

+ 3
- 0
mkit.ini View File

33
     doc     = [ENV:PREFIX]/share/doc/saturnin-demo
33
     doc     = [ENV:PREFIX]/share/doc/saturnin-demo
34
     etc     = /etc/saturnin-demo
34
     etc     = /etc/saturnin-demo
35
     etc_bc  = /etc/bash_completion.d
35
     etc_bc  = /etc/bash_completion.d
36
+    sfincb  = [ENV:PREFIX]/share/shellfu/include-bash
36
 
37
 
37
 [tokens]
38
 [tokens]
38
     __SATURNIN_DATA_HOME__    = [ENV:XDG_DATA_HOME]/saturnin-demo
39
     __SATURNIN_DATA_HOME__    = [ENV:XDG_DATA_HOME]/saturnin-demo
52
     etc_bc  = src/complete.bash              saturnin-demo.bash
53
     etc_bc  = src/complete.bash              saturnin-demo.bash
53
     libexec = src/libexec/saturnin-demo-dump
54
     libexec = src/libexec/saturnin-demo-dump
54
     libexec = src/libexec/saturnin-demo-echo
55
     libexec = src/libexec/saturnin-demo-echo
56
+    libexec = src/libexec/saturnin-demo-greet
57
+    sfincb  = src/shellfu/saturnin_demo_greet.sh
55
     share   = src/help
58
     share   = src/help
56
     share   = src/ini.d
59
     share   = src/ini.d
57
 
60
 

+ 17
- 0
packaging/debian/control View File

20
  shellfu-bash-pretty,
20
  shellfu-bash-pretty,
21
  shellfu-bash-saturnin (>= 0.4.8),
21
  shellfu-bash-saturnin (>= 0.4.8),
22
  shellfu-bash-saturnin (<< 5.0),
22
  shellfu-bash-saturnin (<< 5.0),
23
+ shellfu-bash-saturnin_demo,
23
 Description: __MKIT_PROJ_NAME__ - __MKIT_PROJ_TAGLINE__
24
 Description: __MKIT_PROJ_NAME__ - __MKIT_PROJ_TAGLINE__
24
  saturnin is Shellfu library that helps you easily build toolkit from
25
  saturnin is Shellfu library that helps you easily build toolkit from
25
  various scripts that you may have lying around.  Instead of having a
26
  various scripts that you may have lying around.  Instead of having a
30
  This package contains a demo meta-command built with saturnin; you can
31
  This package contains a demo meta-command built with saturnin; you can
31
  also re-use the source as template for your new toolkit.
32
  also re-use the source as template for your new toolkit.
32
 
33
 
34
+Package: shellfu-bash-saturnin_demo
35
+Architecture: all
36
+Depends:
37
+ shellfu (>= 0.10),
38
+ shellfu (<< 0.11),
39
+ shellfu-bash-pretty,
40
+Description: __MKIT_PROJ_NAME__ - __MKIT_PROJ_TAGLINE__
41
+ saturnin is Shellfu library that helps you easily build toolkit from
42
+ various scripts that you may have lying around.  Instead of having a
43
+ herd of untamed undocumented and hard-to-share scripts, with help of
44
+ saturnin you can easily create and package a meta-command with a set
45
+ of discoverable and maintainable sub-commands.
46
+ .
47
+ This sub-package contains Shellfu/Bash modules used by
48
+ *saturnin-demo*.
49
+
33
 # control file built with MKit __MKIT_SELF_VERSION__
50
 # control file built with MKit __MKIT_SELF_VERSION__

+ 2
- 1
packaging/debian/rules View File

13
 	make clean
13
 	make clean
14
 	make install PREFIX=/usr DESTDIR=TEST
14
 	make install PREFIX=/usr DESTDIR=TEST
15
 	make test \
15
 	make test \
16
-		PATH="$(shell pwd)/TEST/usr/bin:$(PATH)"
16
+		PATH="$(shell pwd)/TEST/usr/bin:$(PATH)" \
17
+		SHELLFU_PATH="$(shell pwd)/TEST/usr/share/shellfu/include-bash"

packaging/debian/install → packaging/debian/saturnin-demo.install View File

2
 /usr/bin/saturnin-demo
2
 /usr/bin/saturnin-demo
3
 /usr/libexec/saturnin-demo/saturnin-demo-dump
3
 /usr/libexec/saturnin-demo/saturnin-demo-dump
4
 /usr/libexec/saturnin-demo/saturnin-demo-echo
4
 /usr/libexec/saturnin-demo/saturnin-demo-echo
5
+/usr/libexec/saturnin-demo/saturnin-demo-greet
5
 /usr/share/doc/saturnin-demo/README.md
6
 /usr/share/doc/saturnin-demo/README.md
6
 /usr/share/saturnin-demo/help
7
 /usr/share/saturnin-demo/help
7
 /usr/share/saturnin-demo/ini.d/main/echo.ini
8
 /usr/share/saturnin-demo/ini.d/main/echo.ini

+ 1
- 0
packaging/debian/shellfu-saturnin_demo.install View File

1
+/usr/share/shellfu/include-bash/saturnin_demo_greet.sh

+ 15
- 1
packaging/template.spec View File

1
+%define sfincb %{_datadir}/shellfu/include-bash
1
 %define shellfu_req shellfu >= 0.10.4, shellfu < 0.11
2
 %define shellfu_req shellfu >= 0.10.4, shellfu < 0.11
2
 %define saturnin_req shellfu-bash-saturnin >= 0.4.10, shellfu-bash-saturnin < 0.5
3
 %define saturnin_req shellfu-bash-saturnin >= 0.4.10, shellfu-bash-saturnin < 0.5
3
 
4
 
14
 
15
 
15
 Requires:   %shellfu_req
16
 Requires:   %shellfu_req
16
 Requires:   %saturnin_req
17
 Requires:   %saturnin_req
18
+Requires:   shellfu-bash-saturnin_demo
17
 %description
19
 %description
18
 saturnin is Shellfu library that helps you easily build toolkit from
20
 saturnin is Shellfu library that helps you easily build toolkit from
19
 various scripts that you may have lying around.  Instead of having a
21
 various scripts that you may have lying around.  Instead of having a
24
 This package contains a demo meta-command built with saturnin; you can
26
 This package contains a demo meta-command built with saturnin; you can
25
 also re-use the source as template for your new toolkit.
27
 also re-use the source as template for your new toolkit.
26
 
28
 
29
+%package -n shellfu-bash-saturnin_demo
30
+Summary: Shellfu/Bash modules for saturnin-demo
31
+Requires: %saturnin_req
32
+Requires: shellfu-bash
33
+Requires: shellfu-bash-pretty
34
+%description -n shellfu-bash-saturnin_demo
35
+This sub-package contains Shellfu/Bash modules used by *saturnin-demo*.
36
+
27
 %prep
37
 %prep
28
 %setup -q
38
 %setup -q
29
 
39
 
35
 
45
 
36
 %check
46
 %check
37
 make test \
47
 make test \
38
-    PATH="%{buildroot}/%{_bindir}:$PATH"
48
+    PATH="%{buildroot}/%{_bindir}:$PATH" \
49
+    SHELLFU_PATH="%{buildroot}/%{sfincb}"
39
 
50
 
40
 %files
51
 %files
41
 %config %{_sysconfdir}/bash_completion.d/%{name}.bash
52
 %config %{_sysconfdir}/bash_completion.d/%{name}.bash
49
 %{_datadir}/%{name}/ini.d/main/echo.ini
60
 %{_datadir}/%{name}/ini.d/main/echo.ini
50
 %{_libexecdir}/%{name}/%{name}-dump
61
 %{_libexecdir}/%{name}/%{name}-dump
51
 %{_libexecdir}/%{name}/%{name}-echo
62
 %{_libexecdir}/%{name}/%{name}-echo
63
+%{_libexecdir}/%{name}/%{name}-greet
52
 
64
 
65
+%files -n shellfu-bash-saturnin_demo
66
+%{sfincb}/saturnin_demo_greet.sh
53
 
67
 
54
 %changelog
68
 %changelog
55
 
69
 

+ 34
- 0
src/libexec/saturnin-demo-greet View File

1
+#!/bin/bash
2
+
3
+. "$(sfpath)" || exit 3
4
+
5
+shellfu import pretty
6
+
7
+shellfu import saturnin_demo_greet
8
+
9
+usage() {
10
+    mkusage "$@" \
11
+        "-u [USER]" \
12
+        "[-w]" \
13
+      -c \
14
+        "-u [USER]    greet user USER or current user" \
15
+        "-w           greet the world (default mode)"
16
+}
17
+
18
+main() {
19
+    local mode=world
20
+    local user=
21
+    while true; do case $1 in
22
+        -u) mode=user; user=$2; break ;;
23
+        -w) mode=world; break ;;
24
+        "") break ;;
25
+        *) usage -w "unknown argument: $1" ;;
26
+    esac done
27
+    debug -v mode user
28
+    case $mode in
29
+        user)   saturnin_demo_greet__user "$user" ;;
30
+        world)  saturnin_demo_greet__world ;;
31
+    esac
32
+}
33
+
34
+main "$@"

+ 21
- 0
src/shellfu/saturnin_demo_greet.sh View File

1
+#!/bin/bash
2
+
3
+shellfu import pretty
4
+
5
+saturnin_demo_greet__world() {
6
+    #
7
+    # Greet the world
8
+    #
9
+    think "greeting the world"
10
+    echos "Hello, world!"
11
+}
12
+
13
+saturnin_demo_greet__user() {
14
+    #
15
+    # Greet user $1 or $USER
16
+    #
17
+    local user=${1:-$USER}
18
+    debug -v user
19
+    think "greeting user: $user"
20
+    echos "Hello, $user!"
21
+}