blob: 99049a4bdd322b6e95acdb3dba7d1c6566a50e02 (
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
#!/bin/sh
#
# Global wrapper function dispatching to the various sh-ves subcommands.
#
ves() {
if [ -z "$SH_VES_INIT" ]; then
printf "ERROR: sh-ves is not initialized. Source ves-init.sh first.\n" >&2
return 1
fi
if [ "$#" -lt 1 ]; then
printf "ERROR: Please specify a command.\n" >&2
ves_help >&2
return 1
fi
# extract the appropriate command
case $1 in
create)
shift
ves_create "$@"
;;
delete)
shift
ves_delete "$@"
;;
var-add)
shift
ves_var_add "$@"
;;
var-rm)
shift
ves_var_rm "$@"
;;
export)
shift
ves_export "$@"
;;
unset)
shift
ves_unset "$@"
;;
show)
shift
ves_show "$@"
;;
copy)
shift
ves_copy "$@"
;;
rename)
shift
ves_rename "$@"
;;
run)
shift
ves_run "$@"
;;
switch)
shift
ves_switch "$@"
;;
list)
shift
ves_list "$@"
;;
envs)
shift
ves_envs "$@"
;;
activate)
shift
ves_activate "$@"
;;
deactivate)
shift
ves_deactivate "$@"
;;
prompt)
shift
"$SHVES_BIN"/ves-prompt.sh "$@"
;;
help|--help|-h)
ves_help
;;
*)
printf "ERROR: Invalid command [%s]\n" "$1" >&2
ves_help >&2
return 1
;;
esac
}
ves_help() {
cat <<'EOF'
usage: ves <command> [arguments]
commands:
create [--override] <name> create a new environment
delete <name> delete an environment
copy <src> <dst> copy an environment
rename <old> <new> rename an environment
activate <name> activate an environment
deactivate deactivate the active environment
switch <name> deactivate, then activate <name>
run <name> <command...> run a command inside an environment
export [--env=<name>] <var> <val> set a variable in an environment
unset [--env=<name>] <var> remove a variable from an environment
show [<name>] show the variables of an environment
var-add [--env=<name>] [--append] <var> <val>
prepend (or append) an entry to a
path-like variable
var-rm [--env=<name>] <var> <val> remove an entry from a path-like variable
list [--index] <var> list the entries of a path-like variable
envs list all environments
prompt [symbol] print a prompt fragment for PS1
help show this message
EOF
}
|