Browse Source

Move main() to the saturnin.sh module

Alois Mahdal 8 years ago
parent
commit
e1eacaa297
2 changed files with 29 additions and 29 deletions
  1. 1
    29
      src/bin/satcmd.skel
  2. 28
    0
      src/shellfu/saturnin.sh

+ 1
- 29
src/bin/satcmd.skel View File

@@ -36,32 +36,4 @@ shellfu import saturnin
36 36
 export SHELLFU_INIGREP_PATH SHELLFU_PATH SHELLFU_PRETTY_USAGE \
37 37
        SATURNIN_CACHE_HOME
38 38
 
39
-main() {
40
-    local subcommand
41
-    while true; do case $1 in
42
-        -d|--debug)     export SHELLFU_DEBUG=true; shift   ;;
43
-        -v|--verbose)   export SHELLFU_VERBOSE=true; shift ;;
44
-        --version)      saturnin__version; exit            ;;
45
-        --version-semver) echo "$SATURNIN_APP_VERSION"; exit ;;
46
-        -*)             saturnin__usage;                ;;
47
-        --*)            saturnin__usage;                ;;
48
-        --)             shift; break                    ;;
49
-        "")             saturnin__usage;                ;;
50
-        *)              break;                          ;;
51
-    esac done
52
-    subcommand="$1"; shift
53
-    debug -v subcommand
54
-    debug -v SHELLFU_PATH SATURNIN_LIBEXEC SHELLFU_INIGREP_PATH
55
-    debug "\$*='$*'"
56
-    case "$subcommand" in
57
-        conf)               inigrep "$@"    ;;
58
-        help)               saturnin__help ;;
59
-        _ls_subcommands)    saturnin__lssc ;;
60
-        _lsfun)             shellfu-get lsfun ;;
61
-        _lsmod)             shellfu-get lsmod ;;
62
-        _ffrun)             ffrun "$@" ;;
63
-        *)                  saturnin__runsc "$subcommand" "$@" ;;
64
-    esac
65
-}
66
-
67
-main "$@"
39
+saturnin__main "$@"

+ 28
- 0
src/shellfu/saturnin.sh View File

@@ -32,6 +32,34 @@ saturnin__lssc() {
32 32
       | sort
33 33
 }
34 34
 
35
+saturnin__main() {
36
+    local subcommand
37
+    while true; do case $1 in
38
+        -d|--debug)     export SHELLFU_DEBUG=true; shift   ;;
39
+        -v|--verbose)   export SHELLFU_VERBOSE=true; shift ;;
40
+        --version)      saturnin__version; exit            ;;
41
+        --version-semver) echo "$SATURNIN_APP_VERSION"; exit ;;
42
+        -*)             saturnin__usage;                ;;
43
+        --*)            saturnin__usage;                ;;
44
+        --)             shift; break                    ;;
45
+        "")             saturnin__usage;                ;;
46
+        *)              break;                          ;;
47
+    esac done
48
+    subcommand="$1"; shift
49
+    debug -v subcommand
50
+    debug -v SHELLFU_PATH SATURNIN_LIBEXEC SHELLFU_INIGREP_PATH
51
+    debug "\$*='$*'"
52
+    case "$subcommand" in
53
+        conf)               inigrep "$@"    ;;
54
+        help)               saturnin__help ;;
55
+        _ls_subcommands)    saturnin__lssc ;;
56
+        _lsfun)             shellfu-get lsfun ;;
57
+        _lsmod)             shellfu-get lsmod ;;
58
+        _ffrun)             ffrun "$@" ;;
59
+        *)                  saturnin__runsc "$subcommand" "$@" ;;
60
+    esac
61
+}
62
+
35 63
 saturnin__runhook() {
36 64
     #
37 65
     # Run custom hook