22# shellcheck disable=SC3043
33
44# Helpers
5- die () { ERR=$1 ; shift ; warn " $@ " ; exit " $ERR " ; }
6- say () { printf ' %s\n' " $@ " ; }
7- warn () { say " $@ " >&2 ; }
8- emit () { printf " ${INDENT} %s\n" " $@ " ; }
9- noop () { : ; }
5+ die () { ERR=$1 ; shift ; warn " $@ " ; exit " $ERR " ; }
6+ say () { printf ' %s\n' " $@ " ; }
7+ warn () { say " $@ " >&2 ; }
8+ emit () { printf " ${INDENT} %s\n" " $@ " ; }
9+ noop () { : ; }
1010is_cmd () { command -v " $1 " > /dev/null 2>&1 ; }
1111is_cmd local || alias local=noop
1212
@@ -15,8 +15,6 @@ is_cmd local || alias local=noop
1515# TAB=$'\t'
1616# SEP=$'\x1F'
1717INDENT=
18- LPAREN=' ('
19- RPAREN=' )'
2018
2119script_fpath () {
2220 if [ " ${O_FPATH_RULE:- append} " = append ]; then
@@ -64,47 +62,53 @@ temp_dir() {
6462
6563antidote_help () {
6664 case " $1 " in
67- home)
68- say " $ANTIDOTE_HOME_HELP "
69- ;;
70- init)
71- say " $ANTIDOTE_INIT_HELP "
72- ;;
73- list)
74- say " $ANTIDOTE_LIST_HELP "
75- ;;
76- * )
77- say " $ANTIDOTE_HELP "
78- ;;
65+ bundle) say " $ANTIDOTE_BUNDLE_HELP " ;;
66+ home) say " $ANTIDOTE_HOME_HELP " ;;
67+ init) say " $ANTIDOTE_INIT_HELP " ;;
68+ list) say " $ANTIDOTE_LIST_HELP " ;;
69+ path) say " $ANTIDOTE_PATH_HELP " ;;
70+ purge) say " $ANTIDOTE_PURGE_HELP " ;;
71+ update) say " $ANTIDOTE_UPDATE_HELP " ;;
72+ * ) say " $ANTIDOTE_HELP " ;;
7973 esac
8074}
8175
8276antidote_bundle () {
8377 antidote_script " $@ "
8478}
8579
86- antidote_update () {
87- :
88- }
89-
9080antidote_home () {
9181 say " $ANTIDOTE_HOME "
9282}
9383
94- antidote_purge () {
95- :
84+ antidote_init () {
85+ say " #!/usr/bin/env zsh"
86+ say " function antidote {"
87+ say " case \"\$ 1\" in"
88+ say " bundle)"
89+ say " source <( \" ${ANTIDOTE_SCRIPT} \" \"\$ @\" ) || \" ${ANTIDOTE_SCRIPT} \" \"\$ @\" "
90+ say " ;;"
91+ say " *)"
92+ say " \" ${ANTIDOTE_SCRIPT} \" \"\$ @\" "
93+ say " ;;"
94+ say " esac"
95+ say " }"
9696}
9797
9898antidote_list () {
9999 :
100100}
101101
102+ antidote_purge () {
103+ :
104+ }
105+
102106antidote_path () {
103107 :
104108}
105109
106- antidote_init () {
107- say " $ANTIDOTE_INIT "
110+ antidote_update () {
111+ :
108112}
109113
110114bundle_info () {
@@ -302,22 +306,28 @@ antidote() {
302306 say " antidote version $ANTIDOTE_VERSION "
303307 return
304308 ;;
309+ --debug)
310+ ANTIDOTE_DEBUG=true
311+ ;;
305312 esac
306313
307314 if is_cmd " antidote_$1 " ; then
308315 cmd=" antidote_$1 "
309316 shift
310317 " $cmd " " $@ "
311- elif [ " $1 " = info ]; then
312- shift
313- bundle_info " $@ "
318+ elif [ " $ANTIDOTE_DEBUG " = true ]; then
319+ if [ " $1 " = info ]; then
320+ shift
321+ bundle_info " $@ "
322+ fi
314323 else
315324 die 1 " antidote: error: expected command but got \" $1 \" ."
316325 fi
317326}
318327
319328# Set antidote variables.
320329ANTIDOTE_VERSION=2.0.0
330+ ANTIDOTE_SCRIPT=" $( cd " $( dirname " $0 " ) " && pwd) /$( basename " $0 " ) "
321331# shellcheck disable=SC3028
322332: " ${ANTIDOTE_OSTYPE:= ${OSTYPE:- $(uname -s | tr ' [:upper:]' ' [:lower:]' )} } "
323333: " ${ANTIDOTE_GIT_SITE:= https:// github.com} "
@@ -326,7 +336,7 @@ ANTIDOTE_VERSION=2.0.0
326336: " ${ANTIDOTE_COMPATIBILITY_MODE:= } "
327337
328338ANTIDOTE_HELP=$(
329- cat << 'EOF '
339+ cat << 'EOS '
330340antidote - the cure to slow zsh plugin management
331341
332342usage: antidote [<flags>] <command> [<args> ...]
@@ -346,33 +356,47 @@ commands:
346356 list List cloned bundles
347357 path Print the path of a cloned bundle
348358 init Initialize the shell for dynamic bundles
349- EOF
359+ EOS
360+ )
361+
362+ ANTIDOTE_BUNDLE_HELP=$(
363+ cat << 'EOS '
364+ Usage: antidote bundle [<bundles>...]
365+
366+ Clones a bundle and prints its source line.
367+
368+ Flags:
369+ -h, --help Show context-sensitive help.
370+
371+ Args:
372+ [<bundles>] Bundle list.
373+ EOS
350374)
351375
352376ANTIDOTE_HOME_HELP=$(
353- cat << 'EOF '
377+ cat << 'EOS '
354378usage: antidote home
355379
356380Prints where antidote is cloning bundles.
357381
358382Flags:
359383 -h, --help Show context-sensitive help.
360- EOF
384+ EOS
361385)
362386
363387ANTIDOTE_INIT_HELP=$(
364- cat << 'EOF '
388+ cat << 'EOS '
365389usage: antidote init
366390
367391Initializes the shell so antidote can load bundles dynmically.
368392
369393Flags:
370394 -h, --help Show context-sensitive help.
371- EOF
395+ EOS
372396)
373397
374398ANTIDOTE_LIST_HELP=$(
375- cat << 'EOF '
399+ cat << 'EOS '
376400usage: antidote list [-d|--details] [-bcprsu]
377401
378402Lists all currently installed bundles
@@ -388,23 +412,52 @@ Format flags:
388412 -r Bundle's short repo name.
389413 -s Bundle's SHA.
390414 -u Bundle's URL.
391- EOF
415+ EOS
392416)
393417
394- ANTIDOTE_INIT=$(
395- cat << EOF
396- #!/usr/bin/env zsh
397- function antidote {
398- case "\$ 1" in
399- bundle${RPAREN}
400- source <${LPAREN} antidote-main \$ @ ${RPAREN} || antidote-main \$ @
401- ;;
402- *${RPAREN}
403- antidote-main \$ @
404- ;;
405- esac
406- }
407- EOF
418+ ANTIDOTE_PATH_HELP=$(
419+ cat << 'EOS '
420+ usage: antidote path <bundle>
421+
422+ Prints the path of a currently cloned bundle.
423+
424+ Flags:
425+ -h, --help Show context-sensitive help.
426+
427+ Args:
428+ <bundle> The Bundle path to print.
429+ EOS
430+ )
431+
432+ ANTIDOTE_PURGE_HELP=$(
433+ cat << 'EOS '
434+ usage: antidote purge <bundle>
435+
436+ Purges a bundle from your computer.
437+
438+ Flags:
439+ -h, --help Show context-sensitive help.
440+
441+ Args:
442+ <bundle> The bundle to be purged.
443+ EOS
444+ )
445+
446+ ANTIDOTE_UPDATE_HELP=$(
447+ cat << 'EOS '
448+ usage: antidote update [-b|--bundles] [-s|--self]
449+ antidote update <bundle>
450+
451+ Updates cloned bundle(s) and antidote itself.
452+
453+ Flags:
454+ -h, --help Show context-sensitive help.
455+ -s, --self Update antidote.
456+ -b, --bundles Update bundles.
457+
458+ Args:
459+ <bundle> The bundle to be updated.
460+ EOS
408461)
409462
410463# Run antidote!
0 commit comments