summaryrefslogtreecommitdiff
path: root/bin/vm
diff options
context:
space:
mode:
authorMarc Vertes <mvertes@free.fr>2021-02-28 14:05:43 +0100
committerMarc Vertes <mvertes@free.fr>2021-02-28 14:05:43 +0100
commit9e34d600e3d8f8e50b8b87779c76c62924f41d2f (patch)
treedede4b66fddc95fbc444ddc6f3d799b6a8ce4e46 /bin/vm
parenta4f62573788d3d3d25c0bd1d9c443a8e56577a6f (diff)
update
Diffstat (limited to 'bin/vm')
-rwxr-xr-xbin/vm65
1 files changed, 65 insertions, 0 deletions
diff --git a/bin/vm b/bin/vm
new file mode 100755
index 0000000..22886d8
--- /dev/null
+++ b/bin/vm
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+# vm is a tool to manage virtual machines.
+
+vm_version='vm-0.1'
+unset CDPATH
+export LC_ALL=C IFS='
+'
+
+add() {
+ usage 'add name' 'Add a new VM' && return
+ echo 'not implemented yet'
+}
+
+del() {
+ usage 'del name' 'Delete a VM' && return
+ echo 'not implemented yet'
+}
+
+die() { echo "$0: fatal: $@" >&2; exit 1; }
+
+help() {
+ usage 'help' 'Print this help text' && return
+ printf "$vm_version\nUsage: vm command [options] [args]\n"
+ Opth=1; for c in $Cmdlist; do $c; done
+}
+
+info() {
+ usage 'info name' 'Print informations on a VM' && return
+ echo 'not implemented yet'
+}
+
+list() {
+ usage 'list' 'list VMs' && return
+ echo 'not implemented yet'
+}
+
+start() {
+ usage 'start name' 'Start a VM' && return
+ echo 'not implemented yet'
+}
+
+stop() {
+ usage 'stop name' 'Stop a VM' && return
+ echo 'not implemented yet'
+}
+
+usage() { [ "$Opth" ] && printf " %-34s %s\n" "$1" "$2"; }
+
+version() {
+ usage 'version' 'Print version' && return
+ echo "$vm_version"
+}
+
+# Main starts here.
+Cmdlist='add del info help list start stop version'
+[ "$1" ] && C=$1 && shift 1 || { help; exit 1; }
+for c in $Cmdlist
+do
+ case $c in
+ ($C) cmd=$c; break;;
+ ($C*) [ "$cmd" ] && die "ambiguous command $C" || cmd=$c;;
+ esac
+done
+[ "$cmd" ] || die "no command \"$C\"" && $cmd "$@"