Browse Source

Simplify command validation and help

Alois Mahdal 9 years ago
parent
commit
78d51c25a3
1 changed files with 3 additions and 17 deletions
  1. 3
    17
      src/libexec/saturnin-iam

+ 3
- 17
src/libexec/saturnin-iam View File

@@ -14,24 +14,10 @@ ffoo import saturnin_zleep
14 14
 # self help
15 15
 #
16 16
 
17
-available_commands() {
18
-    echo afk
19
-    echo at
20
-    echo back
21
-    echo gone
22
-    echo ooo
23
-    echo wfh
24
-    echo undocking
25
-    echo zleeping
26
-}
17
+available_commands="afk at back gone ooo wfh undocking zleeping"
27 18
 
28 19
 usage() {
29
-    cmd_hint=$(
30
-        available_commands \
31
-            | head -c -1 \
32
-            | tr '\n' '|'
33
-    )
34
-    mkusage "$cmd_hint"
20
+    mkusage $available_commands
35 21
 }
36 22
 
37 23
 
@@ -133,7 +119,7 @@ cmd=$1
133 119
 
134 120
 test -n "$cmd" || usage
135 121
 
136
-available_commands | grep -qse ^$1 || usage
122
+echo $available_commands | grep -qw "$cmd" || usage
137 123
 
138 124
 shift
139 125