Skip to content

Commit

Permalink
feat: display version via version sub command
Browse files Browse the repository at this point in the history
Signed-off-by: Vladislav Doster <mvdoster@gmail.com>
  • Loading branch information
vladdoster committed Dec 17, 2022
1 parent 59975d7 commit bfb01e6
Show file tree
Hide file tree
Showing 8 changed files with 265 additions and 186 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linting.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
# run: commitlint --from=$(git cherry origin/main | head -n 1 | awk '{print $2}')

- name: markdown
run: find . -name '*.md' ! -name 'CHANGELOG.md' -name '*.md' -type f -print0 | xargs -0 -n1 -P4 mdformat --check --wrap 120
run: find . -name '*.md' ! -name 'CHANGELOG.md' -type f -print0 | xargs -0 -n1 -P4 mdformat --check --wrap 120 --number

# - name: shell (shfmt)
# run: find . -name '*.sh' -type f -print0 | xargs -0 -n1 -P4 shfmt -bn -ci -d -i 2 -ln bash -s -sr
Expand Down
289 changes: 146 additions & 143 deletions README.md

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions _zinit
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ commands=(
dunload:'revert changes recorded between dstart and dstop'
dreport:"report what was going on in session"
dclear:'clear report of what was going on in session'
version:'display zinit version'
compile:'compile plugin (or all plugins if --all passed)'
uncompile:'remove compiled version of plugin (or of all plugins if --all passed)'
compiled:'show which plugins are compiled'
Expand Down Expand Up @@ -74,6 +75,9 @@ case $state in
help)
_message "Hit enter to get usage information" && ret=0
;;
version)
_message "display zinit version" && ret=0
;;
man)
_message "Hit enter to view manual" && ret=0
;;
Expand Down
16 changes: 8 additions & 8 deletions doc/HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## README: Update the table of content

1. Install [doctoc](https://github.com/thlorenz/doctoc)
1. To update the TOC run the following command:
2. To update the TOC run the following command:

```zsh
doctoc --github README.md
Expand All @@ -12,7 +12,7 @@ doctoc --github README.md
## Update asciidoc and/or zshelldoc

1. Make sure you have [docker](https://www.docker.com/) or [podman](https://podman.io/) installed.
1. From the root of the repo, run:
2. From the root of the repo, run:

```zsh
make doc-container
Expand All @@ -21,14 +21,14 @@ make doc-container
If for some reason you want to build the zshelldocs or the PDF manually, you'll need:

1. Patience, zsd is very finicky about locales. You have been warned.
1. [zshelldoc (zsd)](https://github.com/zdharma-continuum/zshelldoc)
1. [asciidoc](https://asciidoc.org/)
1. `make doc`
2. [zshelldoc (zsd)](https://github.com/zdharma-continuum/zshelldoc)
3. [asciidoc](https://asciidoc.org/)
4. `make doc`

## Generate the manpage (doc/zinit.1)

1. Install [pandoc](https://pandoc.org/)
1. From the root of the repo run:
2. From the root of the repo run:

```zsh
pandoc --standalone --to man README.md -o doc/zinit.1
Expand All @@ -44,8 +44,8 @@ git checkout documentation
```

2. Do your modifications and push your changes
1. Keep an eye on [the CI logs](https://github.com/zdharma-continuum/zinit/actions/workflows/gh-pages.yaml)
1. If all went well you can head to https://zdharma-continuum.github.io/ to see your changes live.
3. Keep an eye on [the CI logs](https://github.com/zdharma-continuum/zinit/actions/workflows/gh-pages.yaml)
4. If all went well you can head to https://zdharma-continuum.github.io/ to see your changes live.

**NOTE:** If you really **need** to push directly, without CI please refer to \[the README in the
documentation\]https://github.com/zdharma-continuum/zinit/blob/documentation/README.md
Expand Down
22 changes: 21 additions & 1 deletion doc/zsdoc/zinit-autoload.zsh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ FUNCTIONS
.zinit-update-or-status-all
.zinit-update-or-status-snippet
.zinit-wait-for-update-jobs
zi::version

DETAILS
-------
Expand Down Expand Up @@ -774,7 +775,7 @@ ____
User-action entry point.
____
Has 66 line(s). Doesn't call other functions.
Has 67 line(s). Doesn't call other functions.
Called by:
Expand Down Expand Up @@ -1407,3 +1408,22 @@ Called by:
.zinit-update-all-parallel
zi::version
~~~~~~~~~~~
____
Shows usage information.
User-action entry point.
____
Has 2 line(s). Calls functions:
zi::version
`-- zinit.zsh/+zinit-message
Called by:
zinit.zsh/zinit
8 changes: 6 additions & 2 deletions doc/zsdoc/zinit.zsh.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ DETAILS
Script Body
~~~~~~~~~~~
Has 245 line(s). Calls functions:
Has 249 line(s). Calls functions:
Script-Body
|-- +zinit-message
Expand Down Expand Up @@ -133,6 +133,7 @@ Has 245 line(s). Calls functions:
|   |-- zinit-autoload.zsh/.zinit-unload
|   |-- zinit-autoload.zsh/.zinit-update-or-status
|   |-- zinit-autoload.zsh/.zinit-update-or-status-all
|   |-- zinit-autoload.zsh/zi::version
|   |-- zinit-install.zsh/.zinit-compile-plugin
|   |-- zinit-install.zsh/.zinit-compinit
|   |-- zinit-install.zsh/.zinit-forget-completion
Expand Down Expand Up @@ -191,6 +192,7 @@ Called by:
zinit-autoload.zsh/.zinit-update-or-status-all
zinit-autoload.zsh/.zinit-update-or-status
zinit-autoload.zsh/.zinit-wait-for-update-jobs
zinit-autoload.zsh/zi::version
zinit-install.zsh/.zinit-compile-plugin
zinit-install.zsh/.zinit-compinit
zinit-install.zsh/.zinit-download-file-stdout
Expand Down Expand Up @@ -1284,7 +1286,7 @@ ____
and completion.
____
Has 560 line(s). Calls functions:
Has 564 line(s). Calls functions:
zinit
|-- +zinit-message
Expand Down Expand Up @@ -1320,6 +1322,7 @@ Has 560 line(s). Calls functions:
|-- zinit-autoload.zsh/.zinit-unload
|-- zinit-autoload.zsh/.zinit-update-or-status
|-- zinit-autoload.zsh/.zinit-update-or-status-all
|-- zinit-autoload.zsh/zi::version
|-- zinit-install.zsh/.zinit-compile-plugin
|-- zinit-install.zsh/.zinit-compinit
|-- zinit-install.zsh/.zinit-forget-completion
Expand Down Expand Up @@ -1409,6 +1412,7 @@ Has 1 line(s). Calls functions:
|-- zinit-autoload.zsh/.zinit-unload
|-- zinit-autoload.zsh/.zinit-update-or-status
|-- zinit-autoload.zsh/.zinit-update-or-status-all
|-- zinit-autoload.zsh/zi::version
|-- zinit-install.zsh/.zinit-compile-plugin
|-- zinit-install.zsh/.zinit-compinit
|-- zinit-install.zsh/.zinit-forget-completion
Expand Down
11 changes: 9 additions & 2 deletions zinit-autoload.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -3352,9 +3352,15 @@ EOF
)
} # ]]]


# FUNCTION: zi::version [[[
# Shows usage information.
#
# Help function
#
# User-action entry point.
zi::version() {
+zinit-message "zinit{cmd} $(git --git-dir=$(realpath ${ZINIT[BIN_DIR]}/.git) describe --tags) {rst}(${OSTYPE}_${CPUTYPE})"
return $?
} # ]]]

# FUNCTION: .zinit-help [[[
# Shows usage information.
Expand All @@ -3364,6 +3370,7 @@ EOF
builtin print -r -- "${ZINIT[col-p]}Usage${ZINIT[col-rst]}:
—— -h|--help|help – usage information
—— man – manual
—— version – display zinit version
—— self-update – updates and compiles Zinit
—— zstatus – overall Zinit statu—— 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
—— load ${ZINIT[col-pname]}plg-spec${ZINIT[col-rst]} – load plugin, can also receive absolute local path
Expand Down
99 changes: 70 additions & 29 deletions zinit.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -66,25 +66,63 @@ if [[ -z ${ZINIT[LIST_COMMAND]} ]]; then
fi
fi

ZINIT[ice-list]="svn|proto|from|teleid|bindmap|cloneopts|id-as|depth|if|wait|load|\
unload|blockf|pick|bpick|src|as|ver|silent|lucid|notify|mv|cp|\
atinit|atclone|atload|atpull|nocd|run-atpull|has|cloneonly|make|\
service|trackbinds|multisrc|compile|nocompile|completions|nocompletions|\
reset-prompt|wrap|reset|sh|\!sh|bash|\!bash|ksh|\!ksh|csh|\
\!csh|aliases|countdown|ps-on-unload|ps-on-update|trigger-load|\
light-mode|is-snippet|atdelete|pack|git|verbose|on-update-of|\
subscribe|extract|param|opts|autoload|subst|install|pullopts|\
debug|null|binary|link|configure"
ZINIT[nval-ice-list]="blockf|silent|lucid|trackbinds|cloneonly|nocd|run-atpull|\
nocompletions|sh|\!sh|bash|\!bash|ksh|\!ksh|csh|\!csh|\
aliases|countdown|light-mode|is-snippet|git|verbose|cloneopts|\
pullopts|debug|null|binary|make|nocompile|notify|reset"

ZINIT[cmds]="-h|--help|help|man|self-update|times|zstatus|load|light|unload|snippet|ls|ice|\
update|status|report|delete|loaded|list|cd|create|edit|glance|stress|changes|recently|clist|\
completions|cclear|cdisable|cenable|creinstall|cuninstall|csearch|compinit|dtrace|dstart|dstop|\
dunload|dreport|dclear|compile|uncompile|compiled|cdlist|cdreplay|cdclear|srv|recall|\
env-whitelist|bindkeys|module|add-fpath|fpath|run"
ZINIT[ice-list]="\
\!bash|\!csh|\!ksh|\!sh|\
aliases|as|atclone|atdelete|atinit|atload|atpull|autoload|\
bash|binary|bindmap|blockf|bpick|\
cloneonly|cloneopts|compile|completions|configure|countdown|cp|csh|\
debug|depth|\
extract|\
from|git|\
has|\
id-as|if|install|is-snippet|\
ksh|\
light-mode|link|load|lucid|\
make|multisrc|mv|nocd|nocompile|nocompletions|notify|null|\
on-update-of|opts|\
pack|param|pick|proto|ps-on-unload|ps-on-update|pullopts|\
reset|reset-prompt|run-atpull|\
service|sh|silent|src|subscribe|subst|svn|\
teleid|trackbinds|trigger-load|\
unload|\
ver|verbose|\
wait|wrap"
ZINIT[nval-ice-list]="\
\!bash|\!csh|\!ksh|\!sh|\
aliases|\
bash|binary|blockf|\
cloneonly|cloneopts|countdown|csh|\
debug|\
git|\
is-snippet|\
ksh|\
light-mode|lucid|\
make|\
nocd|nocompile|nocompletions|notify|null|\
pullopts|\
reset|run-atpull|\
sh|silent|\
trackbinds|\
verbose"
ZINIT[cmds]="\
-help|-h|\
add-fpath|\
bindkeys|\
cclear|cd|cdclear|cdisable|cdlist|cdreplay|cenable|changes|clist|compile|compiled|compinit|completions|create|creinstall|csearch|cuninstall|\
dclear|delete|dreport|dstart|dstop|dtrace|dunload|\
edit|env-whitelist|\
fpath|\
glance|\
help|\
ice|\
light|list|load|loaded|ls|\
man|module|\
recall|recently|report|run|\
self-update|snippet|srv|status|stress|\
times|\
uncompile|unload|update|\
version|\
zstatus"

# Can be customized.
: ${ZINIT[COMPLETIONS_DIR]:=${ZINIT[HOME_DIR]}/completions}
Expand Down Expand Up @@ -2551,16 +2589,16 @@ zinit() {
--bindkeys opt_-b,--bindkeys
-x opt_-x,--command:"Load the snippet as a {cmd}command{rst}, i.e.: add it to {var}\$PATH{rst} and set {b-lhi}+x{rst} on it."
--command opt_-x,--command
env-whitelist "-h|--help|-v|--verbose"
update "-L|--plugins|-s|--snippets|-p|--parallel|-a|--all|\
-q|--quiet|-r|--reset|-u|--urge|-n|--no-pager|-v|--verbose|-h|--help"
delete "-a|--all|-c|--clean|-y|--yes|-q|--quiet|-h|--help"
unload "-h|--help|-q|--quiet"
cdclear "-h|--help|-q|--quiet"
cdreplay "-h|--help|-q|--quiet"
times "-h|--help|-m|-s"
light "-h|--help|-b"
snippet "-h|--help|-f|--force|--command|-x"
cdclear "--help|--quiet|-h|-q"
cdreplay "--help|--quiet|-h|-q"
delete "--all|--clean|--help|--quiet|--yes|-a|-c|-h|-q|-y"
env-whitelist "--help|--verbose|-h|-v"
light "--help|-b|-h"
snippet "--command|--force|--help|-f|-h|-x"
times "--help|-h|-m|-s"
unload "--help|--quiet|-h|-q"
update "--all|--help|--no-pager|--parallel|--plugins|--quiet|--reset|--snippets|--urge|--verbose|-L|-a|-h|-n|-p|-q|-r|-s|-u|-v"
version ""
)

cmd="$1"
Expand Down Expand Up @@ -3065,6 +3103,9 @@ You can try to prepend {apo}${___q}{lhi}@{apo}'{error} to the ID if the last ice
(-h|--help|help)
.zinit-help
;;
(version)
zi::version
;;
(ls)
shift
.zinit-ls "$@"
Expand Down

0 comments on commit bfb01e6

Please sign in to comment.