Skip to content

Commit

Permalink
v: Fix the behaviors
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg committed Jul 4, 2020
1 parent 5b7790d commit e61cb39
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/python/v.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ v::command::remove() {
echo "Options:"
echo " -h, --help Show this message."
return 0
elif [ -e ${VENV_NAME_FILE} ]; then
v::error "\"${VENV_NAME_FILE}\" file already exists."
return 1
elif ! [ -z $1 ]; then
# Abort if the name looks like an option (i.e. starts with '-')
if [[ $1 == "-*" ]]; then
Expand All @@ -133,7 +130,11 @@ v::command::remove() {
_v_rm_name="$1"
shift
else
_v_rm_name="$(basename "$(pwd)")"
if [ -e ${VENV_NAME_FILE} ]; then
_v_rm_name=$(cat ${VENV_NAME_FILE})
else
_v_rm_name=$(basename "$(pwd)")
fi

# If there's already a virtual environment with this name, abort.
v::command::list --oneline | while read line; do
Expand Down Expand Up @@ -259,21 +260,19 @@ v::command::help() {
echo -e " ${FG} rm-tmp ${RESET} Remove all temporary virtualenvs"
}


# Main entrypoint
function v() {
. /Users/pradyunsg/Projects/dotfiles/src/python/v.zsh
subcommand=$1
case $subcommand in
case ${subcommand} in
"" | "-h" | "--help")
v::command::help
;;
*)
# Check if there's a subcommand by that name
if ! typeset -f v::command::${subcommand} > /dev/null; then
FG="\e[31m"
echo -e "${FG}ERROR: '$subcommand' is not a known subcommand.${RESET}" >&2
RESET="\e[0m"
echo -e "${FG}ERROR: '$subcommand' is not a known subcommand.${RESET}" >&2
return 1
fi

Expand Down

0 comments on commit e61cb39

Please sign in to comment.