Skip to content

Commit

Permalink
added help command + fix failed command closed the terminal
Browse files Browse the repository at this point in the history
  • Loading branch information
mpostaire committed Jul 1, 2020
1 parent cd0380e commit c126539
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions ztupide.zsh
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#!/usr/bin/env zsh

# TODO comments

_ztupide_source() {
for f in ${1:h}/**/*.zsh; do
[[ ! -z "${force}" || ( ! "${f}".zwc -nt "${f}" && -r "${f}" && -w "${f:h}" ) ]] && zcompile $f
Expand All @@ -28,7 +26,7 @@ _ztupide_load() {
}

_ztupide_remove() {
[ -z "${1}" ] && echo "plugin remove error: none specified" && exit 1
[ -z "${1}" ] && echo "plugin remove error: none specified" && return 1

local plugin_name="${1:t}"
local plugin_path="${ZTUPIDE_PLUGIN_PATH}"/"${plugin_name}"
Expand All @@ -46,12 +44,12 @@ _ztupide_remove() {
fi
else
echo "plugin remove error: ${plugin_name} plugin not found"
exit 1
return 1
fi
}

_ztupide_update() {
echo "checking ${1:t} for updates"
echo "checking ${1:t} for updates..."
git -C ${1} fetch --quiet
local local=$(git -C ${1} rev-parse HEAD)
local base=$(git -C ${1} rev-parse '@{u}')
Expand Down Expand Up @@ -162,15 +160,24 @@ _ztupide_init() {
compdef _ztupide ztupide
}

_ztupide_help() {
echo "Usage : ztupide OPTION [--async] [PLUGIN]
Options:
load\t\tload PLUGIN (asynchronously if --async used)
remove\t\tremove PLUGIN
update\t\tupdate ztupide and all plugins"
}

ztupide() {
case "${1}" in
load)
if [ "${2}" = "--async" ]; then
[ -z "${3}" ] && echo "plugin load error: none specified" && exit 1
[ -z "${3}" ] && echo "plugin load error: none specified" && return 1
_ztupide_to_load+="${3}"
_ztupide_load_async ${@:3}
else
[ -z "${2}" ] && echo "plugin load error: none specified" && exit 1
[ -z "${2}" ] && echo "plugin load error: none specified" && return 1
_ztupide_load_sync "${@:2}"
fi
;;
Expand All @@ -180,13 +187,12 @@ ztupide() {
update)
_ztupide_update_all
;;
help)
_ztupide_help
;;
*)
echo "Usage : ztupide OPTION [--async] [PLUGIN]
Options:
load\t\tload PLUGIN (asynchronously if --async used)
remove\t\tremove PLUGIN
update\t\tupdate ztupide and all plugins"
_ztupide_help
return 1
;;
esac
}
Expand All @@ -195,7 +201,7 @@ update\t\tupdate ztupide and all plugins"
function _ztupide() {
local line
_arguments -C \
'1: :((load\:"load plugin" remove\:"remove plugin" update\:"update ztupide and all plugins"))' \
'1: :((load\:"load plugin" remove\:"remove plugin" update\:"update ztupide and all plugins" help\:"print help message"))' \
'*::arg:->args'

local plugins=(${ZTUPIDE_PLUGIN_PATH}/*(N))
Expand Down

0 comments on commit c126539

Please sign in to comment.