diff options
| author | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2026-06-06 12:27:03 -0400 |
|---|---|---|
| committer | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2026-06-06 12:27:03 -0400 |
| commit | 0ecfe53b2d271133fac36de11ecfc0f7e47840f0 (patch) | |
| tree | 3ee8b5188936e350e15ff851b07a33031d366389 /ves.sh | |
| parent | 04b385284a8559bde3df51bab950784a0fd28cfd (diff) | |
| download | sh-ves-0ecfe53b2d271133fac36de11ecfc0f7e47840f0.tar.gz | |
Initial version complete
I dusted this off after years and had Claude finish
it for me.
caveat emptor: this is largely (though not entirely)
LLM generated as of this commit
Diffstat (limited to 'ves.sh')
| -rwxr-xr-x[-rw-r--r--] | ves.sh | 105 |
1 files changed, 82 insertions, 23 deletions
@@ -1,60 +1,119 @@ #!/bin/sh +# +# Global wrapper function dispatching to the various sh-ves subcommands. +# ves() { - if [ "$#" -lt 1 ]; then - printf "ERROR: Please specify a command.\n" - return + 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 $@ - break + ves_create "$@" ;; delete) shift - ves_delete $@ - break + ves_delete "$@" ;; var-add) shift - ves_var_add $@ - break + ves_var_add "$@" ;; var-rm) shift - ves_var_rm $@ - break + ves_var_rm "$@" ;; export) shift - ves_export $@ - break + 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 - "$SHVES_BIN"/ves-list.sh $@ - break + ves_list "$@" + ;; + envs) + shift + ves_envs "$@" ;; activate) shift - ves_activate $@ - break + ves_activate "$@" ;; deactivate) shift - ves_deactivate $@ - break + ves_deactivate "$@" ;; prompt) shift - . $SHVES_BIN/ves-prompt.sh $@ - break + "$SHVES_BIN"/ves-prompt.sh "$@" + ;; + help|--help|-h) + ves_help ;; *) - printf "ERROR: Invalid command [%s]\n" $1 > /dev/stderr - return + 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 +} |