1
0
Fork 0
mirror of https://github.com/zdharma-continuum/zinit-annex-meta-plugins.git synced 2024-11-21 12:07:59 +01:00
zinit-annex-meta-plugins/za-meta-plugins-default-ice-cmd
2021-11-19 23:19:20 +01:00

67 lines
2 KiB
Bash

#!/usr/bin/env zsh
# -*- mode: sh; sh-indentation: 4; sh-basic-offset: 4; indent-tabs-mode: nil; -*-
# Copyright (c) 2020 Sebastian Gniazdowski
# License: MIT
za-meta-plugins-default-ice-cmd() {
# Set the base and typically useful options.
builtin emulate -LR zsh
builtin setopt extendedglob warncreateglobal typesetsilent noshortloops rcquotes
(( $+reply && $+REPLY )) || unsetopt warncreateglobal
autoload -Uz is-at-least
local is_58
is-at-least 5.8 && is_58=1
integer retval
[[ $1 == default-ice ]] && { shift; integer eas_subcommand=1; }
integer ibdebug=$+ICE[debug]
# -D - clear out the recognized options
# -E - allow mixing of options and non-options
# -M - allow private arrays for the options
#
# The options are:
# --with/--mod/-m/--use – to pass the desired module(s)
local -a help clear show stats get quiet
zparseopts -D -E -M ${is_58:+} -clear=clear c=clear \
-show=show s=show -stats=stats t=stats -get=get g=get \
-quiet=quiet q=quiet h=help -help=help || retval=1
if [[ $retval -gt 0 || $1 = -* ]] {
+zinit-message "{nl}{error}meta-plugins annex: {msg}Incorrect options" \
"given${${(M)1:#-*}:+ "(bad option: {ehi}$1{rst}{msg})"}." \
"Usage:{rst}{nl}"
help=( -h ) retval=1
}
if (( !$# && !${#help} && !${#show} && !${#clear} && !${#stats} )) {
+zinit-message "{ehi}meta-plugins annex:{rst}{msg} Missing any" \
"ices. Usage:{rst}{nl}"
help=( -h ) retval=1
}
# --help/-h
if (( ${#help} )) {
za-meta-plugins-default-ice-cmd-help-handler
return retval
}
# --show/-s
if (( ${#show} )) {
.za-meta-plugins-show-default-ices
return $?
}
local -A ICES
.zinit-ice "$@"
integer iceret=$?
Zinit_Annex_Meta_Plugins[default-ices]=${(j: :)${(@qkv)ICES}}
+zinit-message "{pre}default-ice:{rst}{msg} Stored the ices{ehi}:{rst}" \
"${(j: :)${(@q-kv)ICES}}.{rst}"
}
# vim:ft=zsh:sw=4:sts=4:et: