mirror of
https://github.com/Findus23/pyLanguagetool.git
synced 2024-09-09 04:13:46 +02:00
add shell completions
these are mostly experimental
This commit is contained in:
parent
cf982565cc
commit
3bfbf3093e
4 changed files with 145 additions and 2 deletions
54
completions/pylanguagetool.bash
Normal file
54
completions/pylanguagetool.bash
Normal file
|
@ -0,0 +1,54 @@
|
|||
# BASH completion script for pylanguagetool
|
||||
# Generated by pycomplete 0.4.0
|
||||
|
||||
_pylanguagetool_99ddd2e4751833f8_complete()
|
||||
{
|
||||
local cur script coms opts com
|
||||
COMPREPLY=()
|
||||
_get_comp_words_by_ref -n : cur words
|
||||
|
||||
# for an alias, get the real script behind it
|
||||
if [[ $(type -t ${words[0]}) == "alias" ]]; then
|
||||
script=$(alias ${words[0]} | sed -E "s/alias ${words[0]}='(.*)'/\\1/")
|
||||
else
|
||||
script=${words[0]}
|
||||
fi
|
||||
|
||||
# lookup for command
|
||||
for word in ${words[@]:1}; do
|
||||
if [[ $word != -* ]]; then
|
||||
com=$word
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
# completing for an option
|
||||
if [[ ${cur} == --* ]] ; then
|
||||
opts="--api-url --clipboard --disabled-categories --disabled-rules --enabled-categories --enabled-only --enabled-rules --explain-rule --help --input-type --lang --mother-tongue --no-color --personal-word-list --picky --preferred-variants --rule-categories --rules --single-line --verbose --version"
|
||||
|
||||
case "$com" in
|
||||
|
||||
|
||||
|
||||
esac
|
||||
|
||||
COMPREPLY=($(compgen -W "${opts}" -- ${cur}))
|
||||
__ltrim_colon_completions "$cur"
|
||||
|
||||
return 0;
|
||||
fi
|
||||
|
||||
# completing for a command
|
||||
if [[ $cur == $com ]]; then
|
||||
coms=""
|
||||
|
||||
COMPREPLY=($(compgen -W "${coms}" -- ${cur}))
|
||||
__ltrim_colon_completions "$cur"
|
||||
|
||||
return 0
|
||||
fi
|
||||
}
|
||||
|
||||
complete -o default -F _pylanguagetool_99ddd2e4751833f8_complete pylanguagetool
|
||||
|
||||
test
|
39
completions/pylanguagetool.fish
Normal file
39
completions/pylanguagetool.fish
Normal file
|
@ -0,0 +1,39 @@
|
|||
# FISH completion script for pylanguagetool
|
||||
# Generated by pycomplete 0.4.0
|
||||
|
||||
function __fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand
|
||||
for i in (commandline -opc)
|
||||
if contains -- $i
|
||||
return 1
|
||||
end
|
||||
end
|
||||
return 0
|
||||
end
|
||||
|
||||
# global options
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l api-url -d 'the URL of the v2 languagetool API, should end with \'/v2/\''
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l clipboard -d 'get text from system clipboard'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l disabled-categories -d 'IDs of categories to be disabled, comma-separated'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l disabled-rules -d 'IDs of rules to be disabled, comma-separated'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l enabled-categories -d 'IDs of categories to be enabled, comma-separated'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l enabled-only -d 'enable only the rules and categories whose IDs are specified with --enabled-rules or --enabled-categories'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l enabled-rules -d 'IDs of rules to be enabled, comma-separated'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l explain-rule -d 'print URLs with more information about rules'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l help -d 'show this help message and exit'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l input-type -d 'if not plaintext'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l lang -d 'A language code like en or en-US, or auto to guess the language automatically (see preferredVariants below). For languages with variants (English, German, Portuguese) spell checking will only be activated when you specify the variant, e.g. en-GB instead of just en.'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l mother-tongue -d 'A language code of the user\'s native language, enabling false friends checks for some language pairs.'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l no-color -d 'don\'t color output'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l personal-word-list -d 'File name of personal dictionary. A private dictionary can be used to add special words that would otherwise be marked as spelling errors.'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l picky -d 'if enabled, additional rules will be activated'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l preferred-variants -d 'Comma-separated list of preferred language variants. The language detector used with language=auto can detect e.g. English, but it cannot decide whether British English or American English is used. Thus this parameter can be used to specify the preferred variants like en-GB and de-AT. Only available with language=auto.'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l rule-categories -d 'show the the categories of the matching rules'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l rules -d 'show the matching rules'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l single-line -d 'check every line on its own'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l verbose -d 'verbose output'
|
||||
complete -c pylanguagetool -n '__fish_pylanguagetool_99ddd2e4751833f8_complete_no_subcommand' -l version -d 'print version and exit'
|
||||
|
||||
# commands
|
||||
|
||||
|
||||
test
|
50
completions/pylanguagetool.zsh
Normal file
50
completions/pylanguagetool.zsh
Normal file
|
@ -0,0 +1,50 @@
|
|||
#compdef pylanguagetool
|
||||
|
||||
# ZSH completion script for pylanguagetool
|
||||
# Generated by pycomplete 0.4.0
|
||||
|
||||
_pylanguagetool_99ddd2e4751833f8_complete()
|
||||
{
|
||||
local state com cur opts
|
||||
|
||||
cur=${words[${#words[@]}]}
|
||||
|
||||
# lookup for command
|
||||
for word in ${words[@]:1}; do
|
||||
if [[ $word != -* ]]; then
|
||||
com=$word
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${cur} == --* ]]; then
|
||||
state="option"
|
||||
opts=("--api-url:the URL of the v2 languagetool API, should end with \'/v2/\'" "--clipboard:get text from system clipboard" "--disabled-categories:IDs of categories to be disabled, comma-separated" "--disabled-rules:IDs of rules to be disabled, comma-separated" "--enabled-categories:IDs of categories to be enabled, comma-separated" "--enabled-only:enable only the rules and categories whose IDs are specified with --enabled-rules or --enabled-categories" "--enabled-rules:IDs of rules to be enabled, comma-separated" "--explain-rule:print URLs with more information about rules" "--help:show this help message and exit" "--input-type:if not plaintext" "--lang:A language code like en or en-US, or auto to guess the language automatically \(see preferredVariants below\). For languages with variants \(English, German, Portuguese\) spell checking will only be activated when you specify the variant, e.g. en-GB instead of just en." "--mother-tongue:A language code of the user\'s native language, enabling false friends checks for some language pairs." "--no-color:don\'t color output" "--personal-word-list:File name of personal dictionary. A private dictionary can be used to add special words that would otherwise be marked as spelling errors." "--picky:if enabled, additional rules will be activated" "--preferred-variants:Comma-separated list of preferred language variants. The language detector used with language=auto can detect e.g. English, but it cannot decide whether British English or American English is used. Thus this parameter can be used to specify the preferred variants like en-GB and de-AT. Only available with language=auto." "--rule-categories:show the the categories of the matching rules" "--rules:show the matching rules" "--single-line:check every line on its own" "--verbose:verbose output" "--version:print version and exit")
|
||||
elif [[ $cur == $com ]]; then
|
||||
state="command"
|
||||
coms=()
|
||||
fi
|
||||
|
||||
case $state in
|
||||
(command)
|
||||
_describe 'command' coms
|
||||
;;
|
||||
(option)
|
||||
case "$com" in
|
||||
|
||||
|
||||
|
||||
esac
|
||||
|
||||
_describe 'option' opts
|
||||
;;
|
||||
*)
|
||||
# fallback to file completion
|
||||
_arguments '*:file:_files'
|
||||
esac
|
||||
}
|
||||
|
||||
_pylanguagetool_99ddd2e4751833f8_complete "$@"
|
||||
|
||||
|
||||
test
|
|
@ -17,8 +17,8 @@ indention = " " * 4
|
|||
def init_config():
|
||||
p = configargparse.ArgParser(default_config_files=["~/.config/pyLanguagetool.conf"],
|
||||
config_file_parser_class=CustomConfigFileParser)
|
||||
p.add_argument("-V", "--version", default=False, action='store_true')
|
||||
p.add_argument("-v", "--verbose", env_var="VERBOSE", default=False, action='store_true')
|
||||
p.add_argument("-V", "--version", default=False, action='store_true', help="print version and exit")
|
||||
p.add_argument("-v", "--verbose", env_var="VERBOSE", default=False, action='store_true', help="verbose output")
|
||||
p.add_argument("-a", "--api-url", env_var="API_URL", default="https://languagetool.org/api/v2/",
|
||||
help="the URL of the v2 languagetool API, should end with '/v2/'")
|
||||
p.add_argument("--no-color", env_var="NO_COLOR", action='store_true', default=False, help="don't color output")
|
||||
|
|
Loading…
Reference in a new issue