#!/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 [arguments] commands: create [--override] create a new environment delete delete an environment copy copy an environment rename rename an environment activate activate an environment deactivate deactivate the active environment switch deactivate, then activate run run a command inside an environment export [--env=] set a variable in an environment unset [--env=] remove a variable from an environment show [] show the variables of an environment var-add [--env=] [--append] prepend (or append) an entry to a path-like variable var-rm [--env=] remove an entry from a path-like variable list [--index] 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 }