Skip to content

Commit

Permalink
fix: re-format zinit usage message
Browse files Browse the repository at this point in the history
Signed-off-by: Doster, Vladislav <[email protected]>
  • Loading branch information
vladdoster committed Jun 9, 2023
1 parent 497d519 commit 0e691c0
Show file tree
Hide file tree
Showing 10 changed files with 373 additions and 417 deletions.
31 changes: 1 addition & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,11 @@ container:
docker build --tag=ghcr.io/zdharma-continuum/zinit:latest --file=docker/Dockerfile .

doc: clean
cd doc; zsh -l -d -f -i -c "zsd -v --scomm --cignore '(\#*FUNCTION:[[:space:]][\:\∞\.\+\@\-a-zA-Z0-9]*[\[]*|}[[:space:]]\#[[:space:]][\]]*)' $(DOC_SRC)"
cd doc; zsh -l -d -f -i -c "zsd -v --scomm --cignore '(\#*FUNCTION:[[:space:]][\:\∞\_\.\+\@\-a-zA-Z0-9]*[\[]*|}[[:space:]]\#[[:space:]][\]]*)' $(DOC_SRC)"

doc/container: container
./scripts/docker-run.sh --docs --debug

# Run ctags to generate Emacs and Vim's format tag file.
tags: tags/emacs tags/vim

tags/emacs: ## Build Emacs-style ctags file
@if type ctags >/dev/null 2>&1; then \
if ctags --version | grep >/dev/null 2>&1 "Universal Ctags"; then \
ctags -e -R --options=share/zsh.ctags --languages=zsh \
--pattern-length-limit=250 --maxdepth=1; \
else \
ctags -e -R --languages=sh --langmap=sh:.zsh; \
fi; \
printf "Created the Emacs \`TAGS\` file.\\n"; \
else \
printf 'Error: Please install a Ctags (e.g.: either the Exuberant or Universal %b' \
'version) utility first.\n'; \
fi

tags/vim: ## Build the Vim-style ctags file
@if type ctags >/dev/null 2>&1; then \
if ctags --version | grep >/dev/null 2>&1 "Universal Ctags"; then \
ctags --languages=zsh --maxdepth=1 --options=share/zsh.ctags --pattern-length-limit=250 -R; \
else \
ctags -R --languages=sh --langmap=sh:.zsh; \
fi; \
printf "Created the Vim's style \`tags\` file.\\n"; \
else \
printf 'Error: Please install a ctags first.\n'; \
fi

test:
zunit run

Expand Down
8 changes: 7 additions & 1 deletion _zinit
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ __zinit_commands(){
'env-whitelist:Specify names (also patterns) of parameters to be left unchanged during an unload'
'glance:Look at plugins source'
'help:Usage information'
'ice:Set ice'
'load:Load plugin'
'man:Display Zinit'\''s manpage'
'module:Manage binary Zsh module shipped with Zinit'
Expand Down Expand Up @@ -236,6 +237,11 @@ _zinit_env_whitelist(){
_zinit_glance(){
_arguments - installed '1:installed:__zinit_installed' && ret=0
} # ]]]
# FUNCTION: _zinit_ice [[[
_zinit_ice(){
_arguments -A \
'(-h --help)'{-h,--help}'[Print usage]' && ret=0
} # ]]]
# FUNCTION: _zinit_list [[[
_zinit_list(){
_message 'Hit enter to list the defined key bindings replay' && ret=0
Expand Down Expand Up @@ -279,7 +285,7 @@ _zinit_snippet(){
_arguments -A \
'(-c --command)'{-c,--command}'[Load the snippet as a command (i.e., make executable and apend to $PATH])' \
'(-f --force)'{-f,--force}'[Force new download of the snippet file]' \
'(-h --help)'{-h,--help}'[Show this help message]'
'(-h --help)'{-h,--help}'[Print usage]'
_arguments - snippet '*::snippet:__zinit_installed_snippets' && ret=0
} # ]]]
# FUNCTION: _zinit_status [[[
Expand Down
Empty file modified doc/zsdoc/_zinit.adoc
100644 → 100755
Empty file.
2 changes: 1 addition & 1 deletion doc/zsdoc/zinit-autoload.zsh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ ____
____

Has 64 line(s). Doesn't call other functions.
Has 63 line(s). Doesn't call other functions.

Called by:

Expand Down
12 changes: 6 additions & 6 deletions doc/zsdoc/zinit-install.zsh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -302,10 +302,10 @@ Has 195 line(s). Calls functions:
|-- .zinit-download-file-stdout
|   `-- zinit.zsh/+zinit-message
|-- .zinit-jq-check
|   `-- zinit.zsh/+zinit-message
|   `-- zinit.zsh/+zi-log
|-- .zinit-json-to-array
|   `-- .zinit-jq-check
|   `-- zinit.zsh/+zinit-message
|   `-- zinit.zsh/+zi-log
|-- ziextract
|   `-- zinit.zsh/+zinit-message
|-- zinit.zsh/+zinit-message
Expand Down Expand Up @@ -379,10 +379,10 @@ ____
____

Has 8 line(s). Calls functions:
Has 3 line(s). Calls functions:

.zinit-jq-check
`-- zinit.zsh/+zinit-message
`-- zinit.zsh/+zi-log

Called by:

Expand All @@ -405,7 +405,7 @@ Has 4 line(s). Calls functions:

.zinit-json-get-value
`-- .zinit-jq-check
`-- zinit.zsh/+zinit-message
`-- zinit.zsh/+zi-log

Not called by script or any function (may be e.g. a hook, a Zle widget, etc.).

Expand All @@ -426,7 +426,7 @@ Has 13 line(s). Calls functions:

.zinit-json-to-array
`-- .zinit-jq-check
`-- zinit.zsh/+zinit-message
`-- zinit.zsh/+zi-log

Uses feature(s): _eval_, _setopt_

Expand Down
20 changes: 16 additions & 4 deletions doc/zsdoc/zinit.zsh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ Has 244 line(s). Calls functions:
|   |-- .zinit-get-object-path
|   |   `-- .zinit-any-to-user-plugin
|   |-- .zinit-ice
|   |   `-- +zi-log
|   |   `-- +zinit-message
|   |-- .zinit-load-ices
|   |   `-- .zinit-get-object-path
|   |   `-- .zinit-any-to-user-plugin
Expand Down Expand Up @@ -225,6 +227,7 @@ Has 1 line(s). Calls functions:

Called by:

.zinit-ice
zinit-additional.zsh/.zinit-debug-clear
zinit-additional.zsh/.zinit-debug-report
zinit-additional.zsh/.zinit-debug-revert
Expand All @@ -233,6 +236,7 @@ Called by:
zinit-additional.zsh/.zinit-debug-stop
zinit-additional.zsh/:zinit-tmp-subst-source
zinit-autoload.zsh/.zinit-unload
zinit-install.zsh/.zinit-jq-check

==== +zinit-deploy-message

Expand Down Expand Up @@ -300,7 +304,6 @@ Called by:
zinit-install.zsh/.zinit-get-latest-gh-r-url-part
zinit-install.zsh/.zinit-get-package
zinit-install.zsh/.zinit-install-completions
zinit-install.zsh/.zinit-jq-check
zinit-install.zsh/.zinit-setup-plugin-dir
zinit-install.zsh/.zinit-update-snippet
zinit-install.zsh/ziextract
Expand Down Expand Up @@ -690,9 +693,13 @@ ____
____

Has 13 line(s). Doesn't call other functions.
Has 32 line(s). Calls functions:

Uses feature(s): _setopt_
.zinit-ice
`-- +zi-log
`-- +zinit-message

Uses feature(s): _setopt_, _zmodload_, _zparseopts_

Called by:

Expand Down Expand Up @@ -1600,10 +1607,11 @@ ____
Entrypoint function directly exposed to user, consumes subcommands with respective arguments,
and completion.
____

Has 553 line(s). Calls functions:
Has 527 line(s). Calls functions:

zinit
|-- +zinit-message
Expand All @@ -1618,6 +1626,8 @@ Has 553 line(s). Calls functions:
|-- .zinit-get-object-path
|   `-- .zinit-any-to-user-plugin
|-- .zinit-ice
|   `-- +zi-log
|   `-- +zinit-message
|-- .zinit-load-ices
|   `-- .zinit-get-object-path
|   `-- .zinit-any-to-user-plugin
Expand Down Expand Up @@ -1776,6 +1786,8 @@ Has 1 line(s). Calls functions:
|-- .zinit-get-object-path
|   `-- .zinit-any-to-user-plugin
|-- .zinit-ice
|   `-- +zi-log
|   `-- +zinit-message
|-- .zinit-load-ices
|   `-- .zinit-get-object-path
|   `-- .zinit-any-to-user-plugin
Expand Down
13 changes: 13 additions & 0 deletions tests/commands.zunit
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,19 @@
assert $output contains 'zinit delete [options] [plugins...]'
assert $state equals 0
}
@test 'zinit help' {
for cmd in '-h' '--help' 'help'; do
run zinit $cmd
assert $output contains 'Usage: zinit [OPTIONS] COMMAND'
assert $state equals 0
done
}
@test 'ice --help' {
run zinit ice --help
assert $output contains 'Usage: zinit ice [-h|--help] [args ...]'
assert $output contains 'Available ice-modifiers:'
assert $state equals 0
}
@test 'delete --all' {
run zinit as'completion' is-snippet for @'https://github.com/docker/cli/blob/master/contrib/completion/zsh/_docker'
assert $state equals 0
Expand Down
99 changes: 49 additions & 50 deletions zinit-autoload.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -1413,53 +1413,52 @@ EOF
#
# User-action entry point.
.zinit-help() {
builtin print -r -- "${ZINIT[col-p]}Usage${ZINIT[col-rst]}:
—— help – usage information
—— bindkeys – lists bindkeys set up by each plugin
—— cd ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – cd into plugin's directory; also support snippets, if feed with URL
—— cdclear [-q] – clear compdef replay list, -q – quiet
—— cdisable ${ZINIT[col-info]}cname${ZINIT[col-rst]} – disable completion \`cname'
—— cdlist – show compdef replay list
—— cdreplay [-q] – replay compdefs (to be done after compinit), -q – quiet
—— cenable ${ZINIT[col-info]}cname${ZINIT[col-rst]} – enable completion \`cname'
—— changes ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – view plugin's git log
—— clist|completions – list completions in use
—— compile ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – compile plugin (or all plugins if ——all passed)
—— compiled – list plugins that are compiled
—— compinit – refresh installed completions
—— create ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – create plugin (also together with Github repository)
—— creinstall ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – install completions for plugin, can also receive absolute local path; -q – quiet
—— csearch – search for available completions from any plugin
—— cuninstall ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – uninstall completions for plugin
—— debug – manage debug mode
—— delete – delete a plugin or snippet
—— edit ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – edit plugin's file with \$EDITOR
—— env-whitelist [-v|-h] {env..} – allows to specify names (also patterns) of variables left unchanged during an unload. -v – verbose
—— glance ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – look at plugin's source (pygmentize, {,source-}highlight)
—— ice <ice specification> – add ICE to next command, argument is e.g. from\"gitlab\"
—— light [-b] ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – light plugin load, without reporting/tracking (-b – do track but bindkey-calls only)
—— load ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – load plugin, can also receive absolute local path
—— loaded|list {keyword} – show what plugins are loaded (filter with \'keyword')
—— ls – list snippets in formatted and colorized manner
—— man – manual
—— module – manage binary Zsh module shipped with Zinit, see \`zinit module help'
—— recall ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]}|URL – fetch saved ice modifiers and construct \`zinit ice ...' command
—— recently ${ZINIT[col-info]}[time-spec]${ZINIT[col-rst]} – show plugins that changed recently, argument is e.g. 1 month 2 days
—— report ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – show plugin's report (or all plugins' if ——all passed)
—— self-update – updates and compiles Zinit
—— snippet [-f] ${ZINIT[col-pname]}{url}${ZINIT[col-rst]} – source local or remote file (by direct URL), -f: force – don't use cache
—— srv {service-id} [cmd] – control a service, command can be: stop,start,restart,next,quit; \`next' moves the service to another Zshell
—— status ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]}|URL – Git status for plugin or svn status for snippet (or for all those if ——all passed)
—— stress ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – test plugin for compatibility with set of options
—— times [-s] [-m] [-a] – statistics on plugin load times, sorted in order of loading; -s – use seconds instead of milliseconds, -m – show plugin loading moments, -a – show both load times and loading moments
—— uncompile ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – remove compiled version of plugin (or of all plugins if ——all passed)
—— unload ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – unload plugin loaded with \`zinit load ...', -q – quiet
—— update [-q] ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]}|URL – Git update plugin or snippet (or all plugins and snippets if ——all passed); besides -q accepts also ——quiet, and also -r/--reset – this option causes to run git reset --hard / svn revert before pulling changes
—— version – display zinit version
—— zstatus – overall Zinit statu
—— add-fpath|fpath ${ZINIT[col-info]}[-f|--front]${ZINIT[col-rst]} \\
${ZINIT[col-pname]}plg-spec ${ZINIT[col-info]}[subdirectory]${ZINIT[col-rst]} – adds given plugin directory to \$fpath; if the second argument is given, it is appended to the directory path; if the option -f/--front is given, the directory path is prepended instead of appended to \$fpath. The ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} can be absolute path
—— run [-l] [plugin] {command} – runs the given command in the given plugin's directory; if the option -l will be given then the plugin should be skipped – the option will cause the previous plugin to be reused"
print -- "Usage: zinit [OPTIONS] COMMAND"
print -- ""
print -- "Zinit is a plugin management system for zsh."
print -- ""
print -- "Commands:"
print -- " bindkeys Lists bindkeys set up by each plugin"
print -- " cd Change directory to a plugin or snippet"
print -- " cdclear Clear compdef replay list"
print -- " cdisable Disable completion"
print -- " cdlist Show compdef replay list"
print -- " cdreplay Replay compdefs"
print -- " cenable Enable completion"
print -- " changes View plugin's git log"
print -- " compile Compile plugin"
print -- " compiled List plugins that are compiled"
print -- " compinit Refresh installed completions"
print -- " completions List completions in use"
print -- " create Create plugin (also together with Github repository)"
print -- " creinstall Install a plugin or local completion"
print -- " csearch Search for available completions from any plugin"
print -- " cuninstall Uninstall completions for plugin"
print -- " debug Manage debug mode"
print -- " delete Delete a plugin or snippet"
print -- " edit Edit plugin's file with \$EDITOR"
print -- " glance Look at plugin's source"
print -- " help Usage information"
print -- " ice Add ICE to next command"
print -- " light Light plugin load, without reporting/tracking"
print -- " load Load plugin, can also receive absolute local path"
print -- " man Manual"
print -- " module Manage binary zsh module shipped with zinit"
print -- " plugins List currently installed plugins"
print -- " recall Fetch saved ice modifiers and construct "zinit ice ..." command"
print -- " recently Show plugins that changed recently"
print -- " report Show plugin's report"
print -- " self-update Update zinit"
print -- " snippet Source local or remote file (by direct URL)"
print -- " snippets List currently installed snippets"
print -- " status Git status for plugin or svn status for snippet"
print -- " stress Test plugin for compatibility with set of options"
print -- " times Statistics on plugin load times, sorted in order of loading"
print -- " uncompile Remove compiled version of plugin"
print -- " unload Unload plugin"
print -- " update Update a plugin or snippet"
print -- " version Display zinit version"
print -- " zstatus Overall zinit status"

integer idx
local type key
Expand All @@ -1474,9 +1473,9 @@ EOF
done
done

local -a ice_order
ice_order=( ${${(s.|.)ZINIT[ice-list]}:#teleid} ${(@)${(@)${(@Akons:|:u)${ZINIT_EXTS[ice-mods]//\'\'/}}/(#s)<->-/}:#(.*|dynamic-unscope)} )
print -- "\nAvailable ice-modifiers:\n\n${ice_order[*]}"
print -- "Run 'zinit COMMAND --help' for more information on a command."
print -- ''
print -- "For more help on how to use Zinit, head to https://github.com/zdharma_continuum/zinit'."
} # ]]]

# FUNCTION: .zinit-list-bindkeys [[[
Expand Down
7 changes: 1 addition & 6 deletions zinit-install.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ builtin source "${ZINIT[BIN_DIR]}/zinit-side.zsh" || {
# that's not the case
.zinit-jq-check() {
command -v jq >/dev/null && return 0

+zinit-message "{error}❌ ERROR: jq binary not found" \
"{nl}{u-warn}Please install jq:{rst}" \
"https://github.com/jqlang/jq" \
"{nl}{u-warn}To do so with zinit, please refer to:{rst}" \
"https://github.com/zdharma-continuum/zinit/wiki/%F0%9F%A7%8A-Recommended-ices#jq"
+zi-log '{e} Missing required dependency {cmd}jq{rst}. Please install it.'
return 1
} # ]]]
# FUNCTION: .zinit-json-get-value [[[
Expand Down
Loading

0 comments on commit 0e691c0

Please sign in to comment.