zsh: improve reuse completion
This commit is contained in:
parent
f691b2129c
commit
b0be6f4b63
|
@ -7,10 +7,19 @@
|
||||||
local curcontext=${curcontext} state state_descr line ret=1
|
local curcontext=${curcontext} state state_descr line ret=1
|
||||||
|
|
||||||
function _reuse_licenses() {
|
function _reuse_licenses() {
|
||||||
local licenses=(
|
local -a licenses
|
||||||
$(reuse supported-licenses 2>&- | cut -d' ' -f1)
|
OLDIFS=${IFS}
|
||||||
)
|
IFS=$'\n'
|
||||||
_values 'license' ${licenses}
|
for line in $(reuse supported-licenses 2>&-); do
|
||||||
|
# remove everything before and including the first whitespace and
|
||||||
|
# everything after and including the first http
|
||||||
|
desc=${${line#*[[:blank:]]}%[[:blank:]]http*}
|
||||||
|
# trim whitespace
|
||||||
|
[[ ${desc} =~ '^\s*(\S.*\S)\s*$' ]] && desc=$match[1] || desc=''
|
||||||
|
licenses+=(${line%% *}:${desc})
|
||||||
|
done
|
||||||
|
IFS=${OLDIFS}
|
||||||
|
_describe -t licenses license licenses && ret=0
|
||||||
}
|
}
|
||||||
|
|
||||||
function _reuse_styles() {
|
function _reuse_styles() {
|
||||||
|
@ -71,10 +80,8 @@ case ${state} in
|
||||||
init:'initialize REUSE project'
|
init:'initialize REUSE project'
|
||||||
lint:'list all non-compliant files'
|
lint:'list all non-compliant files'
|
||||||
spdx:"print the project's bill of materials in SPDX format"
|
spdx:"print the project's bill of materials in SPDX format"
|
||||||
supported-licenses:'list all supported SPDX licenses'
|
{supported-licenses,supported-licences}:'list all supported SPDX licenses'
|
||||||
supported-licences:'list all supported SPDX licences'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
_describe -t subcommands subcommand subcommands && ret=0
|
_describe -t subcommands subcommand subcommands && ret=0
|
||||||
;;
|
;;
|
||||||
(subcommand)
|
(subcommand)
|
||||||
|
@ -87,7 +94,7 @@ case ${state} in
|
||||||
{'(--license)-l','(-l)--license'}'[SPDX Identifier, repeatable]':license:_reuse_licenses \
|
{'(--license)-l','(-l)--license'}'[SPDX Identifier, repeatable]':license:_reuse_licenses \
|
||||||
{'(--year)-y','(-y)--year'}'[year of copyright statement, optional]':year \
|
{'(--year)-y','(-y)--year'}'[year of copyright statement, optional]':year \
|
||||||
{'(--style)-s','(-s)--style'}'[comment style to use, optional]':style:_reuse_styles \
|
{'(--style)-s','(-s)--style'}'[comment style to use, optional]':style:_reuse_styles \
|
||||||
--copyright-style'[copyright style to use, optional]':copyright\ style:_reuse_copyright_styles \
|
--copyright-style'[copyright style to use, optional]':'copyright style':_reuse_copyright_styles \
|
||||||
{'(--template)-t','(-t)--template'}'[name of template to use, optional]':template \
|
{'(--template)-t','(-t)--template'}'[name of template to use, optional]':template \
|
||||||
--exclude-year'[do not include year in statement]' \
|
--exclude-year'[do not include year in statement]' \
|
||||||
--merge-copyrights'[merge copyright lines if copyright statements are identical]' \
|
--merge-copyrights'[merge copyright lines if copyright statements are identical]' \
|
||||||
|
@ -97,6 +104,7 @@ case ${state} in
|
||||||
{'(--recursive)-r','(-r)--recursive'}'[add headers to all files under specified directories recursively]' \
|
{'(--recursive)-r','(-r)--recursive'}'[add headers to all files under specified directories recursively]' \
|
||||||
--skip-unrecognised'[skip files with unrecognised comment styles]' \
|
--skip-unrecognised'[skip files with unrecognised comment styles]' \
|
||||||
--skip-existing'[skip files that already contain SPDX information]' \
|
--skip-existing'[skip files that already contain SPDX information]' \
|
||||||
|
1:path:'_files' \
|
||||||
&& ret=0
|
&& ret=0
|
||||||
;;
|
;;
|
||||||
(download)
|
(download)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user