summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2010-09-25 15:32:27 +0200
committerJonas Smedegaard <dr@jones.dk>2010-09-25 15:32:27 +0200
commite146188cb173dea872168cb9349a3e6e2175788d (patch)
treed0e0d55f7bf516496df9650bb157a2c0ca85372f
parent0e2c7628ec070e635c8d4d449a91000f70033bda (diff)
Implement subcommand find.
-rwxr-xr-xlocalsmsadmin39
1 files changed, 27 insertions, 12 deletions
diff --git a/localsmsadmin b/localsmsadmin
index 5c249ff..9628ef7 100755
--- a/localsmsadmin
+++ b/localsmsadmin
@@ -317,18 +317,33 @@ EOF
;;
esac
;;
-# list|show|view)
-# case "$1" in
-# default|user|group|session)
-# type="$1"; shift
-# response="$(listobject "$type" "$@")" || exit1 "Failed listing $type${response:+ $response}"
-# exit0 "Listing $type: $response."
-# ;;
-# *)
-# exit1 "Cannot list \"$1\" (try \"/help\" to see supported commands)!"
-# ;;
-# esac
-# ;;
+ find)
+ case "$1" in
+ help)
+ cat <<EOF
+Usage:
+/find user keyword
+/find group keyword
+/find session keyword
+/find default keyword
+
+Find and return name of object if it exist
+EOF
+ exit 0
+ ;;
+ default|user|group|session)
+ type="$1"; shift
+ name="$1"; [ -n "$name" ] || exit1 "Internal error (empty name)!"; shift
+ [ -z "$*" ] || exit1 "Internal error (too many options)!"
+ oldname="$(findobjects "$type" "$name")" || exit1 "Internal error${oldname:+ $oldname}"
+ [ -n "$oldname" ] || exit1 "No $type named \"$name\"!"
+ exit0 "$name"
+ ;;
+ *)
+ exit1 "Cannot find \"$1\" (try \"/help\" to see supported commands)!"
+ ;;
+ esac
+ ;;
mission)
case "$1" in
help)