|
@@ -28,6 +28,8 @@ SATURNIN_VERSION="__VERSION__"
|
28
|
28
|
# =====END BUILT PART=====
|
29
|
29
|
#
|
30
|
30
|
|
|
31
|
+ffoo import saturnin_common
|
|
32
|
+
|
31
|
33
|
export FFOO_INIGREP_PATH FFOO_PATH FFOO_PRETTY_USAGE \
|
32
|
34
|
SATURNIN_VERSION SATURNIN_CACHE_HOME
|
33
|
35
|
|
|
@@ -37,69 +39,11 @@ usage() {
|
37
|
39
|
"--version"
|
38
|
40
|
}
|
39
|
41
|
|
40
|
|
-print_help() {
|
41
|
|
- echo ""
|
42
|
|
- echo "built-in sub-commands:"
|
43
|
|
- echo ""
|
44
|
|
- echo " conf"
|
45
|
|
- echo " help"
|
46
|
|
- echo ""
|
47
|
|
- echo "installed sub-commands:"
|
48
|
|
- echo ""
|
49
|
|
- ls_subcommands | sed -e 's/^/ /'
|
50
|
|
- return "$FFOO_EXIT_OK"
|
51
|
|
-}
|
52
|
|
-
|
53
|
|
-ls_subcommands() {
|
54
|
|
- find "$SATURNIN_LIBEXEC" \
|
55
|
|
- -mindepth 1 \
|
56
|
|
- -maxdepth 1 \
|
57
|
|
- -executable \
|
58
|
|
- | sed -e 's/.*saturnin-//' \
|
59
|
|
- | sort
|
60
|
|
-}
|
61
|
|
-
|
62
|
42
|
version_info() {
|
63
|
43
|
echo "$(basename $0) (Smart and ready desktop helper) $SATURNIN_VERSION"
|
64
|
44
|
exit $FFOO_EXIT_OK
|
65
|
45
|
}
|
66
|
46
|
|
67
|
|
-run_hook() {
|
68
|
|
- #
|
69
|
|
- # Run custom hook
|
70
|
|
- #
|
71
|
|
- local hname="$1"
|
72
|
|
- local hook_code
|
73
|
|
- test -n "$SATURNIN_SUBCOMMAND" || {
|
74
|
|
- warn "unknown subcommand, ignoring hook: $hname"
|
75
|
|
- return 0
|
76
|
|
- }
|
77
|
|
- hook_code="$(inigrep -j -p hook.$SATURNIN_SUBCOMMAND.$hname)"
|
78
|
|
- debug -v SATURNIN_SUBCOMMAND hook_code hname
|
79
|
|
- bash -n <<<"$hook_code" || {
|
80
|
|
- warn "syntax errors, ignoring hook: $hname"
|
81
|
|
- return 0
|
82
|
|
- }
|
83
|
|
- eval "$hook_code"
|
84
|
|
-}
|
85
|
|
-
|
86
|
|
-subcommand() {
|
87
|
|
- local sc_es=0 # future exit (return) status
|
88
|
|
- local lexpath="$SATURNIN_LIBEXEC/saturnin-$SATURNIN_SUBCOMMAND"
|
89
|
|
- debug -v lexpath
|
90
|
|
- debug "\$*='$*'"
|
91
|
|
- test -x "$lexpath" || {
|
92
|
|
- warn "invalid sub-command: $SATURNIN_SUBCOMMAND"
|
93
|
|
- print_help
|
94
|
|
- return $FFOO_EXIT_USAGE
|
95
|
|
- }
|
96
|
|
- run_hook pre
|
97
|
|
- "$lexpath" "$@" || return $?
|
98
|
|
- sc_es=$?
|
99
|
|
- run_hook post
|
100
|
|
- return $sc_es
|
101
|
|
-}
|
102
|
|
-
|
103
|
47
|
while true; do case $1 in
|
104
|
48
|
-d|--debug) export FFOO_DEBUG=true; shift ;;
|
105
|
49
|
-v|--verbose) export FFOO_VERBOSE=true; shift ;;
|
|
@@ -120,10 +64,10 @@ shift
|
120
|
64
|
|
121
|
65
|
case "$SATURNIN_SUBCOMMAND" in
|
122
|
66
|
conf) inigrep "$@" ;;
|
123
|
|
- help) print_help ;;
|
124
|
|
- _ls_subcommands) ls_subcommands ;;
|
|
67
|
+ help) saturnin_help ;;
|
|
68
|
+ _ls_subcommands) saturnin_lssc ;;
|
125
|
69
|
_lsfun) ffoom lsfun ;;
|
126
|
70
|
_lsmod) ffoom lsmod ;;
|
127
|
71
|
_ffrun) ffrun "$@" ;;
|
128
|
|
- *) subcommand "$@" ;;
|
|
72
|
+ *) saturnin_runsc "$@" ;;
|
129
|
73
|
esac
|