Allow command line with noun first and (potentially) multiple verbs
authorMartin Schwenke <martin@meltin.net>
Fri, 20 Jun 2014 05:02:59 +0000 (15:02 +1000)
committerMartin Schwenke <martin@meltin.net>
Wed, 25 Jun 2014 10:46:16 +0000 (20:46 +1000)
Signed-off-by: Martin Schwenke <martin@meltin.net>
autocluster

index 7afb74bc56bb93ad16fc9725da0eb70859aff016..6fc78f3e3098edad57ffc889fef1b21aeb644c7f 100755 (executable)
@@ -52,6 +52,10 @@ EOF
     cat <<EOF
 
   commands:
+     base [ create | boot ] ...
+
+     cluster create
+
      create base
            create a base image
 
@@ -1154,6 +1158,26 @@ usage_config_options (){
     usage_smart_display load_config
 }
 
+actions_init ()
+{
+    actions=""
+}
+
+actions_add ()
+{
+    actions="${actions}${actions:+ }$*"
+}
+
+actions_run ()
+{
+    [ -n "$actions" ] || usage
+
+    local a
+    for a in $actions ; do
+       $a
+    done
+}
+
 ######################################################################
 
 post_config_hooks=
@@ -1248,6 +1272,28 @@ t="$1"
 shift
 
 case "$t" in
+    base)
+       actions_init
+       for t in "$@" ; do
+           case "$t" in
+               create|boot) actions_add "base_${t}" ;;
+               *) usage ;;
+           esac
+       done
+       actions_run
+       ;;
+
+    cluster)
+       actions_init
+       for t in "$@" ; do
+           case "$t" in
+               create) actions_add "cluster_${t}" ;;
+               *) usage ;;
+           esac
+       done
+       actions_run
+       ;;
+
     create)
        t="$1"
        shift