22# shellcheck disable=SC2120,SC3043
33
44# Helpers
5- die () { local err= " $1 " ; shift ; warn " $@ " ; exit " $err " ; }
5+ die () { warn " $@ " ; exit " ${ERR :- 1} " ; }
66say () { printf ' %s\n' " $@ " ; }
77warn () { say " $@ " >&2 ; }
88emit () { printf " ${INDENT} %s\n" " $@ " ; }
@@ -61,6 +61,7 @@ temp_dir() {
6161antidote_help () {
6262 case " $1 " in
6363 bundle) say " $ANTIDOTE_BUNDLE_HELP " ;;
64+ help) say " $ANTIDOTE_HELP " ;;
6465 home) say " $ANTIDOTE_HOME_HELP " ;;
6566 init) say " $ANTIDOTE_INIT_HELP " ;;
6667 list) say " $ANTIDOTE_LIST_HELP " ;;
@@ -78,7 +79,7 @@ antidote_bundle() {
7879antidote_home () {
7980 local cachedir slash
8081 if [ $# -gt 0 ]; then
81- die 1 " antidote: error: unexpected '$1 '."
82+ die " antidote: error: unexpected '$1 '."
8283 fi
8384 if [ -n " $ANTIDOTE_HOME " ]; then
8485 say " $ANTIDOTE_HOME "
@@ -122,13 +123,13 @@ antidote_purge() {
122123
123124antidote_path () {
124125 if [ -z " $1 " ]; then
125- die 1 " antidote: error: required argument 'bundle' not provided"
126+ die " antidote: error: required argument 'bundle' not provided"
126127 fi
127128 bundle_info " $1 "
128129 if [ -e " $BUNDLE_PATH " ]; then
129130 say " $BUNDLE_PATH "
130131 else
131- die 1 " antidote: error: '$1 ' does not exist in cloned paths"
132+ die " antidote: error: '$1 ' does not exist in cloned paths"
132133 fi
133134}
134135
@@ -140,7 +141,7 @@ antidote_script() {
140141 # The first param is the bundle.
141142 BUNDLE=" $1 "
142143 if [ -z " $BUNDLE " ]; then
143- die 1 " antidote: error: bundle argument expected"
144+ die " antidote: error: bundle argument expected"
144145 fi
145146 shift
146147
@@ -192,13 +193,13 @@ antidote_script() {
192193 # Validate O_KIND
193194 case " $O_KIND " in
194195 autoload|clone|defer|fpath|path|zsh) ;;
195- * ) die 1 " antidote: error: unexpected kind value: $O_KIND " ;;
196+ * ) die " antidote: error: unexpected kind value: $O_KIND " ;;
196197 esac
197198
198199 # Validate O_FPATH_RULE
199200 case " $O_FPATH_RULE " in
200201 append|prepend) ;;
201- * ) die 1 " antidote: error: unexpected fpath-rule value: $O_FPATH_RULE " ;;
202+ * ) die " antidote: error: unexpected fpath-rule value: $O_FPATH_RULE " ;;
202203 esac
203204
204205 # Set vars
@@ -363,7 +364,7 @@ antidote() {
363364 local cmd
364365 : " ${ANTIDOTE_HOME:= " $( antidote_home) " } "
365366
366- case " $1 " in
367+ case " ${1 :- ?} " in
367368 -h|--help)
368369 antidote_help " $@ "
369370 return
@@ -376,6 +377,10 @@ antidote() {
376377 ANTIDOTE_DEBUG=true
377378 shift
378379 ;;
380+ \? )
381+ antidote_help " $@ "
382+ exit
383+ ;;
379384 esac
380385
381386 if is_cmd " antidote_$1 " ; then
@@ -388,7 +393,7 @@ antidote() {
388393 debug_bundle_info " $@ "
389394 fi
390395 else
391- die 1 " antidote: error: expected command but got \" $1 \" ."
396+ die " antidote: error: expected command but got \" $1 \" ."
392397 fi
393398}
394399
@@ -409,13 +414,13 @@ ANTIDOTE_HELP=$(
409414cat << 'EOS '
410415antidote - the cure to slow zsh plugin management
411416
412- usage : antidote [<flags>] <command> [<args> ...]
417+ Usage : antidote [<flags>] <command> [<args> ...]
413418
414- flags :
419+ Flags :
415420 -h, --help Show context-sensitive help
416421 -v, --version Show application version
417422
418- commands :
423+ Commands :
419424 help Show documentation
420425 load Statically source all bundles from the plugins file
421426 bundle Clone bundle(s) and generate the static load script
445450
446451ANTIDOTE_HOME_HELP=$(
447452cat << 'EOS '
448- usage : antidote home
453+ Usage : antidote home
449454
450455Prints where antidote is cloning bundles.
451456
456461
457462ANTIDOTE_INIT_HELP=$(
458463cat << 'EOS '
459- usage : antidote init
464+ Usage : antidote init
460465
461466Initializes the shell so antidote can load bundles dynmically.
462467
467472
468473ANTIDOTE_LIST_HELP=$(
469474cat << 'EOS '
470- usage : antidote list [-d|--details] [-bcprsu]
475+ Usage : antidote list [-d|--details] [-bcprsu]
471476
472477Lists all currently installed bundles
473478
487492
488493ANTIDOTE_PATH_HELP=$(
489494cat << 'EOS '
490- usage : antidote path <bundle>
495+ Usage : antidote path <bundle>
491496
492497Prints the path of a currently cloned bundle.
493498
501506
502507ANTIDOTE_PURGE_HELP=$(
503508cat << 'EOS '
504- usage : antidote purge <bundle>
509+ Usage : antidote purge <bundle>
505510
506511Purges a bundle from your computer.
507512
515520
516521ANTIDOTE_UPDATE_HELP=$(
517522cat << 'EOS '
518- usage : antidote update [-b|--bundles] [-s|--self]
523+ Usage : antidote update [-b|--bundles] [-s|--self]
519524 antidote update <bundle>
520525
521526Updates cloned bundle(s) and antidote itself.
0 commit comments