summaryrefslogtreecommitdiff
path: root/bin/vm
blob: 4b0e96077f11ad997e00471df8801b2c770a60e5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/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
        echo "$vm_version
Manage virtual machines
Usage: vm command [options] [args]"
        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 "$@"