From 0ecfe53b2d271133fac36de11ecfc0f7e47840f0 Mon Sep 17 00:00:00 2001 From: "Douglas B. Rumbaugh" Date: Sat, 6 Jun 2026 12:27:03 -0400 Subject: 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 --- ves.sh | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 82 insertions(+), 23 deletions(-) mode change 100644 => 100755 ves.sh (limited to 'ves.sh') diff --git a/ves.sh b/ves.sh old mode 100644 new mode 100755 index 28325db..99049a4 --- a/ves.sh +++ b/ves.sh @@ -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 [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 +} -- cgit v1.2.3