Merge pull request #1114 from egorlem/diplodoc
Add completion script for yfm (diplodoc cli)
This commit is contained in:
commit
97804d9b97
|
@ -0,0 +1,156 @@
|
||||||
|
#compdef yfm
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions are met:
|
||||||
|
# * Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# * Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in the
|
||||||
|
# documentation and/or other materials provided with the distribution.
|
||||||
|
# * Neither the name of the zsh-users nor the
|
||||||
|
# names of its contributors may be used to endorse or promote products
|
||||||
|
# derived from this software without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
# DISCLAIMED. IN NO EVENT SHALL ZSH-USERS BE LIABLE FOR ANY
|
||||||
|
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Description
|
||||||
|
# -----------
|
||||||
|
#
|
||||||
|
# Completion script for diplodoc cli v4.49.1 (https://diplodoc.com/en/)
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
# Authors
|
||||||
|
# -------
|
||||||
|
#
|
||||||
|
# * Shohei Yoshida (https://github.com/syohex) <syohex@gmail.com>
|
||||||
|
# * Egor Lem <guezwhoz@gmail.com> / egorlem.com
|
||||||
|
#
|
||||||
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
_yfm_suggest_dir() {
|
||||||
|
_alternative 'directory::_directories' ':current directory:(.)' && return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
_yfm() {
|
||||||
|
local context state state_descr line
|
||||||
|
typeset -A opt_args
|
||||||
|
local ret=1
|
||||||
|
|
||||||
|
local -a commands=(
|
||||||
|
'build:Build documentation in target directory'
|
||||||
|
'publish:Publish built documentation in target aws s3 compatible storage'
|
||||||
|
'translate:Translate documentation from source to target language using configured translation provider'
|
||||||
|
)
|
||||||
|
|
||||||
|
local -a build_flags=(
|
||||||
|
'(-i --input)'{-i,--input}'[Configure path to yfm input directory]:dir:_yfm_suggest_dir'
|
||||||
|
'(-o --output)'{-o,--output}'[Configure path to yfm output directory]:dir:_yfm_suggest_dir'
|
||||||
|
\*{--lang,--langs}'[Configure langs supported by build]:lang'
|
||||||
|
'(-f --output-format)'{-f,--output-format}'[Format of output files]:format:(html md)'
|
||||||
|
'--vars-preset[Select vars preset of documentation]:preset'
|
||||||
|
\*{-v,--vars}'[Values of variables]:variable'
|
||||||
|
'--allow-html[Allow to use HTML in Markdown files]'
|
||||||
|
'--sanitize-html[Toggle transformed HTML sanitizing]'
|
||||||
|
'--add-map-file[Should add all paths of documentation into file.json]'
|
||||||
|
'--remove-hidden-toc-items[Remove hidden pages from the build result]'
|
||||||
|
'--merge-includes[Merge includes syntax during md to md processing]'
|
||||||
|
\*{--resource,--resources}'[Custom resources into statically generated pages]:resource'
|
||||||
|
'--allow-custom-resources[Allow loading custom resources into statically generated pages]'
|
||||||
|
'--static-content[Static content]'
|
||||||
|
'--add-system-meta[Should add system section variables from presets into files meta data]'
|
||||||
|
'*--ignore[Do not process paths matches by glob]:pattern'
|
||||||
|
'--ignore-stage[Ignore tocs with stage]:stage:(skip)'
|
||||||
|
'(-c --config)'{-c,--config}'[Path to the configuration file]:filename:_files'
|
||||||
|
'--build-disabled[Disable building]'
|
||||||
|
'(--template --no-template)--template[Select liquid template engine mode]:template:(all text code)'
|
||||||
|
'(--template --no-template)--no-template[Disable template engine]'
|
||||||
|
'--contributors[Should attach contributors into files]'
|
||||||
|
'--ignore-author-patterns[Ignore authors if they contain passed string]:pattern'
|
||||||
|
'--single-page[Build a single page in the output folder also]'
|
||||||
|
'--no-lint[Disable file linting]'
|
||||||
|
'--changelogs[Toggle processing of experimental changelogs syntax]'
|
||||||
|
'--search[Enable search functionality]'
|
||||||
|
)
|
||||||
|
|
||||||
|
local -a global_flags=(
|
||||||
|
'(- *)--help[Show help message]'
|
||||||
|
'(- *)--version[Output the version number]'
|
||||||
|
\*{-e,--extensions}'[Include external extention on startup]:extension:_files'
|
||||||
|
'(-q --quiet)'{--quiet,-q}'[Start in quiet mode]'
|
||||||
|
'(-s --strict)'{--strict,-s}'[Launch in strict mode]' \
|
||||||
|
)
|
||||||
|
|
||||||
|
_arguments -C \
|
||||||
|
${global_flags[@]} \
|
||||||
|
${build_flags[@]} \
|
||||||
|
'1: :(($commands))' \
|
||||||
|
'*:: :->command_args' && ret=0
|
||||||
|
|
||||||
|
case $state in
|
||||||
|
(command_args)
|
||||||
|
case $words[1] in
|
||||||
|
(build)
|
||||||
|
_arguments \
|
||||||
|
${build_flags[@]} \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
(publish)
|
||||||
|
_arguments \
|
||||||
|
'(-i --input)'{-i,--input}'[Configure path to publish input directory]:dir:_yfm_suggest_dir' \
|
||||||
|
'--endpoint[Endpoint of S3 storage]:url:_urls' \
|
||||||
|
'--bucket[Bucket name of S3 storage]:bucket' \
|
||||||
|
'--prefix[Bucket internal scope of S3 storage]:bucket_internal_scope' \
|
||||||
|
'--access-key-id[Key Id of S3 storage]:key_id' \
|
||||||
|
'--secret-access-key[Secret key of S3 storage]:secret_key' \
|
||||||
|
'(-c --config)'{-c,--config}'[Configure path to publish config]:filename:_files' \
|
||||||
|
'--region[Region of S3 storage]:region' \
|
||||||
|
'--hidden[Do not upload paths matched by glob]:pattern' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
|
||||||
|
(translate)
|
||||||
|
_arguments \
|
||||||
|
'(-i --input)'{-i,--input}'[Configure path to translate input directory]:dir:_yfm_suggest_dir' \
|
||||||
|
'(-o --output)'{-o,--output}'[Configure path to translate output directory]:dir:_yfm_suggest_dir' \
|
||||||
|
'--provider[Configure translation service provider]:provider:(yandex)' \
|
||||||
|
'(-sl --source)'{-sl,--source}'[Language code of the original document in ISO 639-1 format]:language' \
|
||||||
|
'(-tl --target)'{-tl,--target}'[Language code of the translated document in ISO 639-1 format]:language' \
|
||||||
|
'*--files[List of paths need to be translated]:file:_files' \
|
||||||
|
'*--include[A set of rules for filtering sent translation files]:filename:_files' \
|
||||||
|
'*--exclude[A set of rules prohibiting sending files for translation]:filename:_files' \
|
||||||
|
\*{-v,--vars}'[Pass list of variables directory to translation]:variable' \
|
||||||
|
'--dry-run[Do not execute traget translation provider, but only calculate required quota]' \
|
||||||
|
'(-c --config)'{-c,--config}'[Configure path to translate config]:filename:_files' \
|
||||||
|
'--auth[Authorization token for Translation API]:token' \
|
||||||
|
'--folder[ID of the folder to which you have access]:id' \
|
||||||
|
'--glossary[Path to yaml file with glossary translation pairs]:file:_files' \
|
||||||
|
'*:: :_files' \
|
||||||
|
&& ret=0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
_yfm "$@"
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: Shell-Script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# sh-basic-offset: 2
|
||||||
|
# End:
|
||||||
|
# vim: ft=zsh sw=2 ts=2 et
|
Loading…
Reference in New Issue